diff options
author | Ondrej Oprala | 2013-06-14 12:41:30 +0200 |
---|---|---|
committer | Karel Zak | 2013-07-03 10:17:37 +0200 |
commit | cb90e24e804e2f95eadf01e96561749092c858c1 (patch) | |
tree | ddb6c8181d8aa749db571ca9f6a560f205ce169c /libmount/src/tab_update.c | |
parent | libmount: add a generic append_string() function (diff) | |
download | kernel-qcow2-util-linux-cb90e24e804e2f95eadf01e96561749092c858c1.tar.gz kernel-qcow2-util-linux-cb90e24e804e2f95eadf01e96561749092c858c1.tar.xz kernel-qcow2-util-linux-cb90e24e804e2f95eadf01e96561749092c858c1.zip |
libmount: add functions to handle comments in fs tables
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab_update.c')
-rw-r--r-- | libmount/src/tab_update.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c index 1e7f32be0..b83c1dd37 100644 --- a/libmount/src/tab_update.c +++ b/libmount/src/tab_update.c @@ -408,13 +408,14 @@ err: */ static int fprintf_mtab_fs(FILE *f, struct libmnt_fs *fs) { - const char *o, *src, *fstype; + const char *o, *src, *fstype, *comm; char *m1, *m2, *m3, *m4; int rc; assert(fs); assert(f); + comm = mnt_fs_get_comment(fs); src = mnt_fs_get_source(fs); fstype = mnt_fs_get_fstype(fs); o = mnt_fs_get_options(fs); @@ -425,6 +426,8 @@ static int fprintf_mtab_fs(FILE *f, struct libmnt_fs *fs) m4 = o ? mangle(o) : "rw"; if (m1 && m2 && m3 && m4) { + if (comm) + fputs(comm, f); rc = fprintf(f, "%s %s %s %s %d %d\n", m1, m2, m3, m4, mnt_fs_get_freq(fs), @@ -527,6 +530,10 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb) struct libmnt_fs *fs; mnt_reset_iter(&itr, MNT_ITER_FORWARD); + + if (tb->comms && mnt_table_get_intro_comment(tb)) + fputs(mnt_table_get_intro_comment(tb), f); + while(mnt_table_next_fs(tb, &itr, &fs) == 0) { if (upd->userspace_only) rc = fprintf_utab_fs(f, fs); @@ -538,6 +545,8 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb) goto leave; } } + if (tb->comms && mnt_table_get_tailing_comment(tb)) + fputs(mnt_table_get_tailing_comment(tb), f); if (fflush(f) != 0) { rc = -errno; |