From: Karel Zak Date: Wed, 15 Sep 2010 14:31:38 +0000 (+0200) Subject: libmount: add MNT_FS_SWAP flag X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9dd75aa6f25d88e483616b8df2d534408776532f;p=util-linux libmount: add MNT_FS_SWAP flag Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/src/fs.c b/shlibs/mount/src/fs.c index fad5da89..adf99ca4 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 ee33f789..f5958957 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 d5bde746..39f7814e 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 e782b278..b9063c03 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));