mount: allow longer /proc/mounts lines
Based on patch by Natanael Copa <ncopa@alpinelinux.org>: Use a bigger buffer for getmntent_r so we can handle entries with lines longer that 504 chars. This solves issue when running `mount -o remount,rw ...` in a docker container on Fedora 43. ref: https://github.com/k0sproject/k0s/issues/6774 ref: https://lists.busybox.net/pipermail/busybox/2025-December/091859.html function old new delta mount_main 1219 1259 +40 singlemount 1315 1323 +8 verbose_mount 94 96 +2 mount_it_now 358 359 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 51/0) Total: 51 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
1 parent
38e2124b32
commit
daf8ec40e0
2 files changed
+13
-9
No files matched your search
+11
-8
@@ -233,7 +233,6 @@
|
||||
#define BB_MS_INVERTED_VALUE (1u << 31)
|
||||
|
||||
#include "libbb.h"
|
||||
#include "common_bufsiz.h"
|
||||
#if ENABLE_FEATURE_MOUNT_LABEL
|
||||
# include "volume_id.h"
|
||||
#else
|
||||
@@ -457,7 +456,8 @@ static const char mount_option_str[] ALIGN1 =
|
||||
"remount\0" // action flag
|
||||
;
|
||||
|
||||
|
||||
// On Fedora 43, there was a reported case when 512-byte buffers are insufficient
|
||||
enum { GETMNTENT_BUFSIZE = 2 * 1024 };
|
||||
struct globals {
|
||||
#if ENABLE_FEATURE_MOUNT_NFS
|
||||
smalluint nfs_mount_version;
|
||||
@@ -466,10 +466,14 @@ struct globals {
|
||||
unsigned verbose;
|
||||
#endif
|
||||
llist_t *fslist;
|
||||
char getmntent_buf[1];
|
||||
} FIX_ALIASING;
|
||||
enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_buf) };
|
||||
#define G (*(struct globals*)bb_common_bufsiz1)
|
||||
char getmntent_buf[GETMNTENT_BUFSIZE];
|
||||
};
|
||||
|
||||
#define G (*ptr_to_globals)
|
||||
#define INIT_G() do { \
|
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
|
||||
} while (0)
|
||||
|
||||
#define nfs_mount_version (G.nfs_mount_version)
|
||||
#if ENABLE_FEATURE_MOUNT_VERBOSE
|
||||
#define verbose (G.verbose )
|
||||
@@ -478,7 +482,6 @@ enum { GETMNTENT_BUFSIZE = COMMON_BUFSIZE - offsetof(struct globals, getmntent_b
|
||||
#endif
|
||||
#define fslist (G.fslist )
|
||||
#define getmntent_buf (G.getmntent_buf )
|
||||
#define INIT_G() do { setup_common_bufsiz(); } while (0)
|
||||
|
||||
#if ENABLE_FEATURE_MTAB_SUPPORT
|
||||
/*
|
||||
@@ -563,7 +566,7 @@ static void append_mount_options(char **oldopts, const char *newopts)
|
||||
//TODO: do this unconditionally?
|
||||
//this way, newopts of "opt1,opt2,opt1"
|
||||
//will be de-duped into "opt1,opt2" in _both_ cases
|
||||
//(whether or now old opts are empty)
|
||||
//(whether or not old opts are empty)
|
||||
//the only modification needed is to not prepend extra comma
|
||||
//when old opts is "".
|
||||
// Do not insert options which are already there
|
||||
|
||||
+2
-1
@@ -94,7 +94,6 @@ int umount_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int umount_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
int doForce;
|
||||
struct mntent me;
|
||||
FILE *fp;
|
||||
char *fstype = NULL;
|
||||
exitcode_t status = EXIT_SUCCESS;
|
||||
@@ -128,6 +127,8 @@ int umount_main(int argc UNUSED_PARAM, char **argv)
|
||||
if (opt & OPT_ALL)
|
||||
bb_error_msg_and_die("can't open '%s'", bb_path_mtab_file);
|
||||
} else {
|
||||
struct mntent me;
|
||||
|
||||
setup_common_bufsiz();
|
||||
while (getmntent_r(fp, &me, bb_common_bufsiz1, COMMON_BUFSIZE)) {
|
||||
/* Match fstype (fstype==NULL matches always) */
|
||||
|
||||
Reference in new issue
Block a user