diff options
author | Karel Zak | 2010-10-19 15:21:03 +0200 |
---|---|---|
committer | Karel Zak | 2011-01-03 12:28:45 +0100 |
commit | 1bd1cd2c6c02269708f4418b0056b49a53a16ed1 (patch) | |
tree | 0579596a395803254a9a386a7ddf2ffbc9583512 /shlibs/mount/src/tab_parse.c | |
parent | tests: add libmount lock test (diff) | |
download | kernel-qcow2-util-linux-1bd1cd2c6c02269708f4418b0056b49a53a16ed1.tar.gz kernel-qcow2-util-linux-1bd1cd2c6c02269708f4418b0056b49a53a16ed1.tar.xz kernel-qcow2-util-linux-1bd1cd2c6c02269708f4418b0056b49a53a16ed1.zip |
libmount: add LIBMOUNT_{MTAB,FSTAB}
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 | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c index ae390e86e..224fcb68f 100644 --- a/shlibs/mount/src/tab_parse.c +++ b/shlibs/mount/src/tab_parse.c @@ -458,20 +458,22 @@ int mnt_tab_parse_fstab(mnt_tab *tb) DIR *dir = NULL; FILE *f; struct dirent **namelist = NULL; + const char *env; assert(tb); if (!tb) return -EINVAL; num = mnt_tab_get_nents(tb); + env = mnt_getenv_safe("LIBMOUNT_FSTAB"); - /* classic fstab */ - { - f = fopen(_PATH_MNTTAB, "r"); - if (f) { - mnt_tab_parse_stream(tb, f, _PATH_MNTTAB); - fclose(f); - } + f = fopen(env ? : _PATH_MNTTAB, "r"); + if (f) { + mnt_tab_parse_stream(tb, f, _PATH_MNTTAB); + fclose(f); + + if (env) + goto done; /* ignore /etc/fstab.d if $LIBMOUNT_FSTAB defined */ } /* TODO: it would be nice to have a scandir() implementaion that @@ -594,9 +596,10 @@ int mnt_tab_parse_mtab(mnt_tab *tb) mnt_tab *u_tb; mnt_fs *u_fs; mnt_iter itr; + const char *env = mnt_getenv_safe("LIBMOUNT_MTAB"); - if (mnt_has_regular_mtab()) { - rc = mnt_tab_parse_file(tb, _PATH_MOUNTED); + if ((env && !endswith(env, "mountinfo")) || mnt_has_regular_mtab()) { + rc = mnt_tab_parse_file(tb, env ? : _PATH_MOUNTED); if (!rc) return 0; /* system with regular mtab */ } @@ -608,7 +611,7 @@ int mnt_tab_parse_mtab(mnt_tab *tb) return mnt_tab_parse_file(tb, _PATH_PROC_MOUNTS); /* try to read userspace specific information from /var/run/mount */ - u_tb = mnt_new_tab_from_file(MNT_PATH_MOUNTINFO); + u_tb = mnt_new_tab_from_file(env ? : MNT_PATH_MOUNTINFO); if (!u_tb) return 0; /* private mountinfo does not exist */ |