diff options
author | Karel Zak <kzak@redhat.com> | 2010-10-19 15:21:03 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2011-01-03 12:28:45 +0100 |
commit | 1bd1cd2c6c02269708f4418b0056b49a53a16ed1 (patch) | |
tree | 0579596a395803254a9a386a7ddf2ffbc9583512 /shlibs | |
parent | 9e10ad3d5035686e4676c208c7d88f55f1c1a05c (diff) | |
download | util-linux-old-1bd1cd2c6c02269708f4418b0056b49a53a16ed1.tar.gz |
libmount: add LIBMOUNT_{MTAB,FSTAB}
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs')
-rw-r--r-- | shlibs/mount/src/tab_parse.c | 23 | ||||
-rw-r--r-- | shlibs/mount/src/tab_update.c | 5 |
2 files changed, 17 insertions, 11 deletions
diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c index ae390e86..224fcb68 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 */ diff --git a/shlibs/mount/src/tab_update.c b/shlibs/mount/src/tab_update.c index b027a552..83022527 100644 --- a/shlibs/mount/src/tab_update.c +++ b/shlibs/mount/src/tab_update.c @@ -602,7 +602,10 @@ int mnt_prepare_update(mnt_update *upd) mnt_fs_get_optstr(upd->fs))); if (!upd->filename) { - const char *p = mnt_get_writable_mtab_path(); + const char *p = mnt_getenv_safe("LIBMOUNT_MTAB"); + + if (!p) + p = mnt_get_writable_mtab_path(); if (!p) { if (errno) { rc = -errno; |