From 0b3953a33d492336a6d9aa8f7ef200e6dc262281 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 9 Jul 2010 11:15:08 +0200 Subject: [PATCH] libmount: add mnt_fs_get_root() Signed-off-by: Karel Zak --- shlibs/mount/src/fs.c | 16 ++++++++++++++-- shlibs/mount/src/mount.h.in | 2 +- shlibs/mount/src/mount.sym | 6 ++++++ shlibs/mount/src/mountP.h | 2 +- shlibs/mount/src/tab_parse.c | 4 ++-- 5 files changed, 24 insertions(+), 6 deletions(-) diff --git a/shlibs/mount/src/fs.c b/shlibs/mount/src/fs.c index 63da2f20..c8677c70 100644 --- a/shlibs/mount/src/fs.c +++ b/shlibs/mount/src/fs.c @@ -51,7 +51,7 @@ void mnt_free_fs(mnt_fs *fs) free(fs->source); free(fs->tagname); free(fs->tagval); - free(fs->mntroot); + free(fs->root); free(fs->target); free(fs->fstype); free(fs->optstr); @@ -447,6 +447,18 @@ int mnt_fs_set_passno(mnt_fs *fs, int passno) return 0; } +/** + * mnt_fs_get_root: + * @fs: /proc/self/mountinfo entry + * + * Returns: root of the mount within the filesystem or NULL + */ +const char *mnt_fs_get_root(mnt_fs *fs) +{ + assert(fs); + return fs ? fs->root : NULL; +} + /** * mnt_fs_get_id: * @fs: /proc/self/mountinfo entry @@ -475,7 +487,7 @@ int mnt_fs_get_parent_id(mnt_fs *fs) /** * mnt_fs_get_devno: - * @fs: /proc/self/mountinfo + * @fs: /proc/self/mountinfo entry * * Returns: value of st_dev for files on filesystem or 0 in case of error. */ diff --git a/shlibs/mount/src/mount.h.in b/shlibs/mount/src/mount.h.in index 6e76ddb2..d42ab1d6 100644 --- a/shlibs/mount/src/mount.h.in +++ b/shlibs/mount/src/mount.h.in @@ -31,7 +31,6 @@ extern "C" { #include - #define LIBMOUNT_VERSION "@LIBMOUNT_VERSION@" /** @@ -236,6 +235,7 @@ extern int mnt_fs_get_freq(mnt_fs *ent); extern int mnt_fs_set_freq(mnt_fs *ent, int freq); extern int mnt_fs_get_passno(mnt_fs *ent); extern int mnt_fs_set_passno(mnt_fs *ent, int passno); +extern const char *mnt_fs_get_root(mnt_fs *fs); extern int mnt_fs_get_id(mnt_fs *fs); extern int mnt_fs_get_parent_id(mnt_fs *fs); extern dev_t mnt_fs_get_devno(mnt_fs *fs); diff --git a/shlibs/mount/src/mount.sym b/shlibs/mount/src/mount.sym index f3c10689..c4aa8e4f 100644 --- a/shlibs/mount/src/mount.sym +++ b/shlibs/mount/src/mount.sym @@ -133,3 +133,9 @@ global: local: *; }; + + +MOUNT_2.19 { +global: + mnt_fs_get_root; +} MOUNT_2.18; diff --git a/shlibs/mount/src/mountP.h b/shlibs/mount/src/mountP.h index d217e3da..04084e5d 100644 --- a/shlibs/mount/src/mountP.h +++ b/shlibs/mount/src/mountP.h @@ -133,7 +133,7 @@ struct _mnt_fs { char *tagname; /* fstab[1]: tag name - "LABEL", "UUID", ..*/ char *tagval; /* tag value */ - char *mntroot; /* mountinfo[4]: root of the mount within the FS */ + char *root; /* mountinfo[4]: root of the mount within the FS */ char *target; /* mountinfo[5], fstab[2]: mountpoint */ char *fstype; /* mountinfo[9], fstab[3]: filesystem type */ diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c index e7cc7ef4..06bb6486 100644 --- a/shlibs/mount/src/tab_parse.c +++ b/shlibs/mount/src/tab_parse.c @@ -168,8 +168,8 @@ static int mnt_parse_mountinfo_line(mnt_fs *fs, char *s) next_word_skip(&s); /* MOUNTROOT */ - fs->mntroot = next_word(&s); - if (!fs->mntroot) + fs->root = next_word(&s); + if (!fs->root) return 1; /* TARGET (mountpoit) */ -- 2.39.5