mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-10 21:42:00 +03:00
Sync with gnulub c6148bca89e9465fd6ba3a10d273ec4cb58c2dbe.
mountlist: add me_mntroot field on Linux machines. Populate me_mntroot in mount_entry so Linux machines based on /proc/self/mountinfo can distinguish between bind mounts and original mounts. In reality bind mounts aren't treated differently than mountroot=/ mounts by the kernel, but the user often wants these bind mounts distinguished. Currently, this in not used in mc, but probably can be used in future. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
fdc094324d
commit
88612bc618
@ -324,6 +324,8 @@ struct mount_entry
|
||||
{
|
||||
char *me_devname; /* Device node name, including "/dev/". */
|
||||
char *me_mountdir; /* Mount point directory name. */
|
||||
char *me_mntroot; /* Directory on filesystem of device used
|
||||
as root for the (bind) mount. */
|
||||
char *me_type; /* "nfs", "4.2", etc. */
|
||||
dev_t me_dev; /* Device number of me_mountdir. */
|
||||
unsigned int me_dummy:1; /* Nonzero for dummy file systems. */
|
||||
@ -383,6 +385,7 @@ free_mount_entry (struct mount_entry *me)
|
||||
return;
|
||||
g_free (me->me_devname);
|
||||
g_free (me->me_mountdir);
|
||||
g_free (me->me_mntroot);
|
||||
if (me->me_type_malloced)
|
||||
g_free (me->me_type);
|
||||
g_free (me);
|
||||
@ -668,6 +671,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup (mnt->mnt_fsname);
|
||||
me->me_mountdir = g_strdup (mnt->mnt_dir);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (mnt->mnt_type);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
@ -700,7 +704,8 @@ read_file_system_list (int need_fs_type)
|
||||
while (getline (&line, &buf_size, fp) != -1)
|
||||
{
|
||||
unsigned int devmaj, devmin;
|
||||
int target_s, target_e, type_s, type_e, source_s, source_e;
|
||||
int target_s, target_e, type_s, type_e;
|
||||
int source_s, source_e, mntroot_s, mntroot_e;
|
||||
char test;
|
||||
char *dash;
|
||||
int rc;
|
||||
@ -708,11 +713,12 @@ read_file_system_list (int need_fs_type)
|
||||
rc = sscanf (line, "%*u " /* id - discarded */
|
||||
"%*u " /* parent - discarded */
|
||||
"%u:%u " /* dev major:minor */
|
||||
"%*s " /* mountroot - discarded */
|
||||
"%n%*s%n " /* mountroot */
|
||||
"%n%*s%n" /* target, start and end */
|
||||
"%c", /* more data... */
|
||||
&devmaj, &devmin, &target_s, &target_e, &test);
|
||||
if (rc != 3 && rc != 5) /* 5 if %n included in count. */
|
||||
&devmaj, &devmin, &mntroot_s, &mntroot_e, &target_s, &target_e, &test);
|
||||
|
||||
if (rc != 3 && rc != 7) /* 7 if %n included in count. */
|
||||
continue;
|
||||
|
||||
/* skip optional fields, terminated by " - " */
|
||||
@ -729,17 +735,20 @@ read_file_system_list (int need_fs_type)
|
||||
continue;
|
||||
|
||||
/* manipulate the sub-strings in place. */
|
||||
line[mntroot_e] = '\0';
|
||||
line[target_e] = '\0';
|
||||
dash[type_e] = '\0';
|
||||
dash[source_e] = '\0';
|
||||
unescape_tab (dash + source_s);
|
||||
unescape_tab (line + target_s);
|
||||
unescape_tab (line + mntroot_s);
|
||||
|
||||
me = g_malloc (sizeof *me);
|
||||
|
||||
me->me_devname = strdup (dash + source_s);
|
||||
me->me_mountdir = strdup (line + target_s);
|
||||
me->me_type = strdup (dash + type_s);
|
||||
me->me_devname = g_strdup (dash + source_s);
|
||||
me->me_mountdir = g_strdup (line + target_s);
|
||||
me->me_mntroot = g_strdup (line + mntroot_s);
|
||||
me->me_type = g_strdup (dash + type_s);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dev = makedev (devmaj, devmin);
|
||||
/* we pass "false" for the "Bind" option as that's only
|
||||
@ -787,6 +796,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup (mnt->mnt_fsname);
|
||||
me->me_mountdir = g_strdup (mnt->mnt_dir);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (mnt->mnt_type);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type, bind);
|
||||
@ -819,6 +829,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup (fsp->f_mntfromname);
|
||||
me->me_mountdir = g_strdup (fsp->f_mntonname);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = fs_type;
|
||||
me->me_type_malloced = 0;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
@ -845,6 +856,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup (fsp->f_mntfromname);
|
||||
me->me_mountdir = g_strdup (fsp->f_mntonname);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (fsp->f_fstypename);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
@ -876,6 +888,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup (fsd.fd_req.devname);
|
||||
me->me_mountdir = g_strdup (fsd.fd_req.path);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = gt_names[fsd.fd_req.fstype];
|
||||
me->me_type_malloced = 0;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
@ -968,6 +981,7 @@ read_file_system_list (int need_fs_type)
|
||||
me->me_devname =
|
||||
g_strdup (fi.device_name[0] != '\0' ? fi.device_name : fi.fsh_name);
|
||||
me->me_mountdir = g_strdup (re != NULL ? re->name : fi.fsh_name);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (fi.fsh_name);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dev = fi.dev;
|
||||
@ -1020,6 +1034,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup (stats[counter].f_mntfromname);
|
||||
me->me_mountdir = g_strdup (stats[counter].f_mntonname);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (FS_TYPE (stats[counter]));
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
@ -1054,6 +1069,7 @@ read_file_system_list (int need_fs_type)
|
||||
me->me_devname = g_strconcat ("/dev/", mnt.mt_dev, (char *) NULL);
|
||||
#endif
|
||||
me->me_mountdir = g_strdup (mnt.mt_filsys);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_dev = (dev_t) (-1); /* Magic; means not known yet. */
|
||||
me->me_type = "";
|
||||
me->me_type_malloced = 0;
|
||||
@ -1101,6 +1117,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup ((*ent)->mt_resource);
|
||||
me->me_mountdir = g_strdup ((*ent)->mt_directory);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup ((*ent)->mt_fstype);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
@ -1164,6 +1181,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof (*me));
|
||||
me->me_devname = g_strdup (mnt.mnt_special);
|
||||
me->me_mountdir = g_strdup (mnt.mnt_mountp);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (mnt.mnt_fstype);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = MNT_IGNORE (&mnt) != 0;
|
||||
@ -1236,6 +1254,7 @@ read_file_system_list (int need_fs_type)
|
||||
me->me_devname = g_strdup (thisent + vmp->vmt_data[VMT_OBJECT].vmt_off);
|
||||
}
|
||||
me->me_mountdir = g_strdup (thisent + vmp->vmt_data[VMT_STUB].vmt_off);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (fstype_to_string (vmp->vmt_gfstype));
|
||||
me->me_type_malloced = 1;
|
||||
options = thisent + vmp->vmt_data[VMT_ARGS].vmt_off;
|
||||
@ -1280,6 +1299,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = g_malloc (sizeof *me);
|
||||
me->me_devname = g_strdup (dev.f_mntfromname);
|
||||
me->me_mountdir = g_strdup (dev.f_mntonname);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (dev.f_fstypename);
|
||||
me->me_type_malloced = 1;
|
||||
me->me_dummy = ME_DUMMY (me->me_devname, me->me_type);
|
||||
@ -1310,6 +1330,7 @@ read_file_system_list (int need_fs_type)
|
||||
me = mount_list->me_next;
|
||||
g_free (mount_list->me_devname);
|
||||
g_free (mount_list->me_mountdir);
|
||||
g_free (mount_list->me_mntroot);
|
||||
if (mount_list->me_type_malloced)
|
||||
g_free (mount_list->me_type);
|
||||
g_free (mount_list);
|
||||
@ -1348,6 +1369,7 @@ read_file_system_list (int need_fs_type, int all_fs)
|
||||
{
|
||||
g_free (me->me_devname);
|
||||
g_free (me->me_mountdir);
|
||||
g_free (me->me_mntroot);
|
||||
g_free (me->me_type);
|
||||
}
|
||||
else
|
||||
@ -1402,6 +1424,7 @@ read_file_system_list (int need_fs_type, int all_fs)
|
||||
|
||||
me->me_devname = g_strdup (dev);
|
||||
me->me_mountdir = g_strdup (dir);
|
||||
me->me_mntroot = NULL;
|
||||
me->me_type = g_strdup (tp);
|
||||
me->me_dev = de.disk_type;
|
||||
|
||||
@ -1749,6 +1772,7 @@ my_statfs (struct my_statfs *myfs_stats, const char *path)
|
||||
myfs_stats->type = entry->me_dev;
|
||||
myfs_stats->typename = entry->me_type;
|
||||
myfs_stats->mpoint = entry->me_mountdir;
|
||||
myfs_stats->mroot = entry->me_mntroot;
|
||||
myfs_stats->device = entry->me_devname;
|
||||
myfs_stats->avail =
|
||||
((uintmax_t) (getuid ()? fs_use.fsu_bavail : fs_use.fsu_bfree) *
|
||||
@ -1778,6 +1802,7 @@ my_statfs (struct my_statfs *myfs_stats, const char *path)
|
||||
myfs_stats->type = entry->me_dev;
|
||||
myfs_stats->typename = entry->me_type;
|
||||
myfs_stats->mpoint = entry->me_mountdir;
|
||||
myfs_stats->mroot = entry->me_mntroot;
|
||||
myfs_stats->device = entry->me_devname;
|
||||
|
||||
myfs_stats->avail = ((uintmax_t) fs_use.fsu_bfree * fs_use.fsu_blocksize) >> 10;
|
||||
|
@ -23,6 +23,7 @@ struct my_statfs
|
||||
int type;
|
||||
char *typename;
|
||||
const char *mpoint;
|
||||
const char *mroot;
|
||||
const char *device;
|
||||
uintmax_t avail; /* in kB */
|
||||
uintmax_t total; /* in kB */
|
||||
|
Loading…
Reference in New Issue
Block a user