Commit 69bffe26 authored by Pavel Emelyanov's avatar Pavel Emelyanov

kerndat: Make fs-virtualized check report yes/no

Right now it returns the whole struct stat which is excessive.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 19a76494
...@@ -33,6 +33,12 @@ enum { ...@@ -33,6 +33,12 @@ enum {
KERNDAT_FS_STAT_MAX KERNDAT_FS_STAT_MAX
}; };
extern struct stat *kerndat_get_fs_stat(unsigned int which); /*
* Check whether the fs @which with kdevice @kdev
* is the same as host's. If yes, this means that
* the fs mount is shared with host, if no -- it's
* a new (likely virtuzlized) fs instance.
*/
extern int kerndat_fs_virtualized(unsigned int which, u32 kdev);
#endif /* __CR_KERNDAT_H__ */ #endif /* __CR_KERNDAT_H__ */
...@@ -57,7 +57,7 @@ static int kerndat_get_shmemdev(void) ...@@ -57,7 +57,7 @@ static int kerndat_get_shmemdev(void)
return 0; return 0;
} }
struct stat *kerndat_get_fs_stat(unsigned int which) static struct stat *kerndat_get_fs_stat(unsigned int which)
{ {
static struct { static struct {
const char *name; const char *name;
...@@ -103,6 +103,17 @@ struct stat *kerndat_get_fs_stat(unsigned int which) ...@@ -103,6 +103,17 @@ struct stat *kerndat_get_fs_stat(unsigned int which)
return &kstat[which].st; return &kstat[which].st;
} }
int kerndat_fs_virtualized(unsigned int which, u32 kdev)
{
struct stat *host_fs_stat;
host_fs_stat = kerndat_get_fs_stat(which);
if (host_fs_stat == NULL)
return -1;
return (kdev_to_odev(kdev) == host_fs_stat->st_dev) ? 0 : 1;
}
/* /*
* Check whether pagemap reports soft dirty bit. Kernel has * Check whether pagemap reports soft dirty bit. Kernel has
* this functionality under CONFIG_MEM_SOFT_DIRTY option. * this functionality under CONFIG_MEM_SOFT_DIRTY option.
......
...@@ -690,15 +690,17 @@ static int attach_option(struct mount_info *pm, char *opt) ...@@ -690,15 +690,17 @@ static int attach_option(struct mount_info *pm, char *opt)
/* Is it mounted w or w/o the newinstance option */ /* Is it mounted w or w/o the newinstance option */
static int devpts_parse(struct mount_info *pm) static int devpts_parse(struct mount_info *pm)
{ {
struct stat *host_st; int ret;
host_st = kerndat_get_fs_stat(KERNDAT_FS_STAT_DEVPTS);
if (host_st == NULL)
return -1;
if (host_st->st_dev == kdev_to_odev(pm->s_dev)) ret = kerndat_fs_virtualized(KERNDAT_FS_STAT_DEVPTS, pm->s_dev);
return 0; if (ret <= 0)
return ret;
/*
* Kernel hides this option, but if the fs instance
* is new (virtualized) we know that it was created
* with -o newinstance.
*/
return attach_option(pm, "newinstance"); return attach_option(pm, "newinstance");
} }
...@@ -745,15 +747,7 @@ out: ...@@ -745,15 +747,7 @@ out:
static bool rt_detmpfs_match(struct mount_info *pm) static bool rt_detmpfs_match(struct mount_info *pm)
{ {
struct stat *host_st; return kerndat_fs_virtualized(KERNDAT_FS_STAT_DEVTMPFS, pm->s_dev) == 0;
host_st = kerndat_get_fs_stat(KERNDAT_FS_STAT_DEVTMPFS);
if (host_st) {
if (host_st->st_dev == kdev_to_odev(pm->s_dev))
return true;
}
return false;
} }
static int devtmpfs_dump(struct mount_info *pm) static int devtmpfs_dump(struct mount_info *pm)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment