diff options
author | Karel Zak | 2010-03-02 22:34:56 +0100 |
---|---|---|
committer | Karel Zak | 2010-06-03 15:20:11 +0200 |
commit | efe73c3ef120997c14ad95bf1857a044e99872b6 (patch) | |
tree | 518fe139a38ec374aa0a9aa8fb533dc8044dd6ab /shlibs/mount/src/tab_parse.c | |
parent | findmnt: add new command (diff) | |
download | kernel-qcow2-util-linux-efe73c3ef120997c14ad95bf1857a044e99872b6.tar.gz kernel-qcow2-util-linux-efe73c3ef120997c14ad95bf1857a044e99872b6.tar.xz kernel-qcow2-util-linux-efe73c3ef120997c14ad95bf1857a044e99872b6.zip |
libmount: read devno, ID and parent ID from /proc/self/mountinfo
The patch also removes obsolete test program from tab_parse.c.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/tab_parse.c')
-rw-r--r-- | shlibs/mount/src/tab_parse.c | 68 |
1 files changed, 7 insertions, 61 deletions
diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c index feaab74af..f8d6680fd 100644 --- a/shlibs/mount/src/tab_parse.c +++ b/shlibs/mount/src/tab_parse.c @@ -166,6 +166,8 @@ static int mnt_tab_parse_file_line(mnt_fs *fs, char *s) */ static int mnt_parse_mountinfo_line(mnt_fs *fs, char *s) { + unsigned int maj, min; + /* ID */ if (next_number(&s, &fs->id) != 0) return 1; @@ -174,9 +176,12 @@ static int mnt_parse_mountinfo_line(mnt_fs *fs, char *s) if (next_number(&s, &fs->parent) != 0) return 1; - /* <maj>:<min> (ignore) */ - if (next_word_skip(&s) != 0) + /* <maj>:<min> */ + s = skip_spaces(s); + if (!*s || sscanf(s, "%u:%u", &maj, &min) != 2) return 1; + fs->devno = makedev(maj, min); + next_word_skip(&s); /* MOUNTROOT */ fs->mntroot = next_word(&s); @@ -532,62 +537,3 @@ done: return buf; } -#ifdef LIBMOUNT_TEST_PROGRAM -int test_parse(struct mtest *ts, int argc, char *argv[]) -{ - mnt_tab *tb; - mnt_fs *fs; - mnt_iter *itr; - - if (argc != 2) - goto err; - - tb = mnt_new_tab(argv[1]); - if (!tb) - goto err; - if (mnt_tab_parse_file(tb) != 0) - goto err; - if (mnt_tab_get_nerrs(tb)) { - char buf[BUFSIZ]; - - mnt_tab_strerror(tb, buf, sizeof(buf)); - printf("\t%s\n", buf); - goto err; - } - - itr = mnt_new_iter(MNT_ITER_FORWARD); - if (!itr) - goto err; - while(mnt_tab_next_fs(tb, itr, &fs) == 0) { - const char *tg, *vl; - - if (mnt_fs_get_tag(fs, &tg, &vl) == 0) - printf("%s=%s", tg, vl); - else - printf("%s", mnt_fs_get_srcpath(fs)); - - printf("|%s|%s|%s|%d|%d|\n", - mnt_fs_get_target(fs), - mnt_fs_get_fstype(fs), - mnt_fs_get_optstr(fs), - mnt_fs_get_freq(fs), - mnt_fs_get_passno(fs)); - } - mnt_free_tab(tb); - mnt_free_iter(itr); - - return 0; -err: - return -1; -} - -int main(int argc, char *argv[]) -{ - struct mtest tss[] = { - { "--parse", test_parse, "<file> parse the {fs,m}tab or mountinfo file" }, - { NULL } - }; - return mnt_run_test(tss, argc, argv); -} - -#endif /* LIBMOUNT_TEST_PROGRAM */ |