summaryrefslogtreecommitdiffstats
path: root/shlibs
diff options
context:
space:
mode:
authorKarel Zak2010-09-15 16:31:38 +0200
committerKarel Zak2011-01-03 12:28:42 +0100
commit9dd75aa6f25d88e483616b8df2d534408776532f (patch)
treea980021cc0cb19561a39f62383d01ddb7e94ad5a /shlibs
parentlibmount: cleanup debug flags (diff)
downloadkernel-qcow2-util-linux-9dd75aa6f25d88e483616b8df2d534408776532f.tar.gz
kernel-qcow2-util-linux-9dd75aa6f25d88e483616b8df2d534408776532f.tar.xz
kernel-qcow2-util-linux-9dd75aa6f25d88e483616b8df2d534408776532f.zip
libmount: add MNT_FS_SWAP flag
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs')
-rw-r--r--shlibs/mount/src/fs.c21
-rw-r--r--shlibs/mount/src/mountP.h1
-rw-r--r--shlibs/mount/src/tab.c7
-rw-r--r--shlibs/mount/src/tab_parse.c6
4 files changed, 24 insertions, 11 deletions
diff --git a/shlibs/mount/src/fs.c b/shlibs/mount/src/fs.c
index fad5da890..adf99ca4d 100644
--- a/shlibs/mount/src/fs.c
+++ b/shlibs/mount/src/fs.c
@@ -348,6 +348,8 @@ int __mnt_fs_set_fstype(mnt_fs *fs, char *fstype)
fs->flags |= MNT_FS_PSEUDO;
else if (mnt_fstype_is_netfs(fs->fstype))
fs->flags |= MNT_FS_NET;
+ else if (!strcmp(fs->fstype, "swap"))
+ fs->flags |= MNT_FS_SWAP;
return 0;
}
@@ -508,7 +510,7 @@ int mnt_fs_prepend_optstr(mnt_fs *fs, const char *optstr)
if (!rc && v)
rc = mnt_optstr_prepend_option(&fs->vfs_optstr, v, NULL);
if (!rc && f)
- rc = mnt_optstr_prepend_option(&fs->fs_optstr, f, NULL);
+ rc = mnt_optstr_prepend_option(&fs->fs_optstr, f, NULL);
return rc;
}
@@ -844,11 +846,16 @@ int mnt_fs_print_debug(mnt_fs *fs, FILE *file)
fprintf(file, "target: %s\n", mnt_fs_get_target(fs));
fprintf(file, "fstype: %s\n", mnt_fs_get_fstype(fs));
fprintf(file, "optstr: %s\n", mnt_fs_get_optstr(fs));
- fprintf(file, "freq: %d\n", mnt_fs_get_freq(fs));
- fprintf(file, "pass: %d\n", mnt_fs_get_passno(fs));
- fprintf(file, "id: %d\n", mnt_fs_get_id(fs));
- fprintf(file, "parent: %d\n", mnt_fs_get_parent_id(fs));
- fprintf(file, "devno: %d:%d\n", major(mnt_fs_get_devno(fs)),
- minor(mnt_fs_get_devno(fs)));
+ if (mnt_fs_get_freq(fs))
+ fprintf(file, "freq: %d\n", mnt_fs_get_freq(fs));
+ if (mnt_fs_get_passno(fs))
+ fprintf(file, "pass: %d\n", mnt_fs_get_passno(fs));
+ if (mnt_fs_get_id(fs))
+ fprintf(file, "id: %d\n", mnt_fs_get_id(fs));
+ if (mnt_fs_get_parent_id(fs))
+ fprintf(file, "parent: %d\n", mnt_fs_get_parent_id(fs));
+ if (mnt_fs_get_devno(fs))
+ fprintf(file, "devno: %d:%d\n", major(mnt_fs_get_devno(fs)),
+ minor(mnt_fs_get_devno(fs)));
return 0;
}
diff --git a/shlibs/mount/src/mountP.h b/shlibs/mount/src/mountP.h
index ee33f7892..f59589577 100644
--- a/shlibs/mount/src/mountP.h
+++ b/shlibs/mount/src/mountP.h
@@ -175,6 +175,7 @@ struct _mnt_fs {
*/
#define MNT_FS_PSEUDO (1 << 1) /* pseudo filesystem */
#define MNT_FS_NET (1 << 2) /* network filesystem */
+#define MNT_FS_SWAP (1 << 3) /* swap device */
/*
* mtab/fstab/mountinfo file
diff --git a/shlibs/mount/src/tab.c b/shlibs/mount/src/tab.c
index d5bde746a..39f7814e4 100644
--- a/shlibs/mount/src/tab.c
+++ b/shlibs/mount/src/tab.c
@@ -449,8 +449,11 @@ mnt_fs *mnt_tab_find_target(mnt_tab *tb, const char *path, int direction)
mnt_reset_iter(&itr, direction);
while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
char *p;
- if (!fs->target)
+
+ if (!fs->target || !(fs->flags & MNT_FS_SWAP) ||
+ (*fs->target == '/' && *(fs->target + 1) == '\0'))
continue;
+
p = mnt_resolve_path(fs->target, tb->cache);
if (strcmp(cn, p) == 0)
return fs;
@@ -546,6 +549,8 @@ mnt_fs *mnt_tab_find_srcpath(mnt_tab *tb, const char *path, int direction)
if (ntags <= mnt_tab_get_nents(tb)) {
mnt_reset_iter(&itr, direction);
while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
+ if (fs->flags & (MNT_FS_NET | MNT_FS_PSEUDO))
+ continue;
p = mnt_fs_get_srcpath(fs);
if (p)
p = mnt_resolve_path(p, tb->cache);
diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c
index e782b2781..b9063c035 100644
--- a/shlibs/mount/src/tab_parse.c
+++ b/shlibs/mount/src/tab_parse.c
@@ -352,7 +352,7 @@ static int mnt_tab_parse_next(mnt_tab *tb, FILE *f, mnt_fs *fs,
s = skip_spaces(buf);
} while (*s == '\0' || *s == '#');
- DBG(TAB, mnt_debug_h(tb, "%s:%d: %s", filename, *nlines, s));
+ /*DBG(TAB, mnt_debug_h(tb, "%s:%d: %s", filename, *nlines, s));*/
if (!tb->fmt)
tb->fmt = detect_fmt(s);
@@ -374,13 +374,13 @@ static int mnt_tab_parse_next(mnt_tab *tb, FILE *f, mnt_fs *fs,
if (!fs->optstr)
return -ENOMEM;
}
-
+/*
DBG(TAB, mnt_debug_h(tb, "%s:%d: SOURCE:%s, MNTPOINT:%s, TYPE:%s, "
"OPTS:%s, FREQ:%d, PASSNO:%d",
filename, *nlines,
fs->source, fs->target, fs->fstype,
fs->optstr, fs->freq, fs->passno));
-
+*/
return 0;
err:
DBG(TAB, mnt_debug_h(tb, "%s:%d: parse error", tb, filename, *nlines));