summaryrefslogtreecommitdiffstats
path: root/shlibs
diff options
context:
space:
mode:
authorKarel Zak2010-07-21 14:01:56 +0200
committerKarel Zak2011-01-03 12:28:40 +0100
commit6a493fa3769684971c9c47163d47e9687fb9d0f0 (patch)
tree78dc46b0957f942ba6d8b8478f344513a998f488 /shlibs
parentlibmount: add {start,end}swith() functions (diff)
downloadkernel-qcow2-util-linux-6a493fa3769684971c9c47163d47e9687fb9d0f0.tar.gz
kernel-qcow2-util-linux-6a493fa3769684971c9c47163d47e9687fb9d0f0.tar.xz
kernel-qcow2-util-linux-6a493fa3769684971c9c47163d47e9687fb9d0f0.zip
libmount: remove fs and tab printf functions
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs')
-rw-r--r--shlibs/mount/src/fs.c112
-rw-r--r--shlibs/mount/src/mount.h.in19
-rw-r--r--shlibs/mount/src/mount.sym3
-rw-r--r--shlibs/mount/src/tab.c84
-rw-r--r--shlibs/mount/src/tab_parse.c3
5 files changed, 2 insertions, 219 deletions
diff --git a/shlibs/mount/src/fs.c b/shlibs/mount/src/fs.c
index 0cd2eaa5b..0c9e06ea0 100644
--- a/shlibs/mount/src/fs.c
+++ b/shlibs/mount/src/fs.c
@@ -682,118 +682,6 @@ int mnt_fs_match_options(mnt_fs *fs, const char *options)
return mnt_match_options(fs->optstr, options);
}
-/* Unfortunately the classical Unix /etc/mtab and /etc/fstab
- do not handle directory names containing spaces.
- Here we mangle them, replacing a space by \040.
- What do other Unices do? */
-
-static unsigned char need_escaping[] = { ' ', '\t', '\n', '\\' };
-
-static char *mangle(const char *s)
-{
- char *ss, *sp;
- int n;
-
- n = strlen(s);
- ss = sp = malloc(4*n+1);
- if (!sp)
- return NULL;
- while(1) {
- for (n = 0; n < sizeof(need_escaping); n++) {
- if (*s == need_escaping[n]) {
- *sp++ = '\\';
- *sp++ = '0' + ((*s & 0300) >> 6);
- *sp++ = '0' + ((*s & 070) >> 3);
- *sp++ = '0' + (*s & 07);
- goto next;
- }
- }
- *sp++ = *s;
- if (*s == 0)
- break;
- next:
- s++;
- }
- return ss;
-}
-
-/**
- * mnt_fprintf_line:
- * @f: FILE
- * @fmt: printf-like format string (see MNT_TAB_PRINTFMT)
- * @source: (spec) device name or tag=value
- * @target: mountpoint
- * @fstype: filesystem type
- * @options: mount options
- * @freq: dump frequency in days
- * @passno: pass number on parallel fsck
- *
- * It's recommended to use this function rather than directly call fprintf() to
- * write an entry to mtab/fstab. All data in these files has to be properly
- * formatted (for example space within paths/tags has to be escaped, see
- * fstab(5) for more details).
- *
- * Returns: return value from fprintf().
- */
-int mnt_fprintf_line( FILE *f,
- const char *fmt,
- const char *source,
- const char *target,
- const char *fstype,
- const char *options,
- int freq,
- int passno)
-{
- char *m1 = NULL, *m2 = NULL, *m3 = NULL, *m4 = NULL;
- int rc = -1;
-
- if (!f || !fmt || !source || !target || !fstype || !options)
- return -1;
-
- m1 = mangle(source);
- m2 = mangle(target);
- m3 = mangle(fstype);
- m4 = mangle(options);
-
- if (!m1 || !m2 || !m3 || !m4)
- goto done;
-
- rc = fprintf(f, fmt, m1, m2, m3, m4, freq, passno);
-done:
- free(m1);
- free(m2);
- free(m3);
- free(m4);
-
- return rc;
-}
-
-/**
- * mnt_fs_fprintf:
- * @fs: fstab/mtab/mountinfo entry
- * @f: FILE
- * @fmt: printf-like format string (see MNT_TAB_PRINTFMT)
- *
- * Returns: return value from fprintf().
- */
-int mnt_fs_fprintf(mnt_fs *fs, FILE *f, const char *fmt)
-{
- assert(fs);
- assert(f);
- assert(fmt);
-
- if (!fs || !f)
- return -1;
-
- return mnt_fprintf_line(f, fmt,
- mnt_fs_get_source(fs),
- mnt_fs_get_target(fs),
- mnt_fs_get_fstype(fs),
- mnt_fs_get_optstr(fs),
- mnt_fs_get_freq(fs),
- mnt_fs_get_passno(fs));
-}
-
/**
* mnt_fs_print_debug
* @fs: fstab/mtab/mountinfo entry
diff --git a/shlibs/mount/src/mount.h.in b/shlibs/mount/src/mount.h.in
index 46934a988..9a6280426 100644
--- a/shlibs/mount/src/mount.h.in
+++ b/shlibs/mount/src/mount.h.in
@@ -252,21 +252,6 @@ extern int mnt_fs_match_target(mnt_fs *fs, const char *target, mnt_cache *cache)
extern int mnt_fs_match_source(mnt_fs *fs, const char *source, mnt_cache *cache);
extern int mnt_fs_match_fstype(mnt_fs *fs, const char *types);
extern int mnt_fs_match_options(mnt_fs *fs, const char *options);
-
-/* mtab/fstab line */
-#define MNT_TAB_PRINTFMT "%s %s %s %s %d %d\n"
-
-extern int mnt_fprintf_line(
- FILE *f,
- const char *fmt,
- const char *source,
- const char *target,
- const char *fstype,
- const char *options,
- int freq,
- int passno);
-
-extern int mnt_fs_fprintf(mnt_fs *ent, FILE *f, const char *fmt);
extern int mnt_fs_print_debug(mnt_fs *ent, FILE *file);
/* tab-parse.c */
@@ -303,10 +288,6 @@ extern int mnt_tab_find_next_fs(mnt_tab *tb, mnt_iter *itr,
int (*match_func)(mnt_fs *, void *), void *userdata,
mnt_fs **fs);
-extern int mnt_tab_fprintf(mnt_tab *tb, FILE *f, const char *fmt);
-extern int mnt_tab_update_file(mnt_tab *tb, const char *filename);
-
-
/*
* mount(8) userspace options masks (MNT_MAP_USERSPACE map)
*/
diff --git a/shlibs/mount/src/mount.sym b/shlibs/mount/src/mount.sym
index 5596d87cc..a33c7f261 100644
--- a/shlibs/mount/src/mount.sym
+++ b/shlibs/mount/src/mount.sym
@@ -10,7 +10,6 @@ global:
mnt_cache_find_tag;
mnt_cache_find_tag_value;
mnt_cache_read_tags;
- mnt_fprintf_line;
mnt_free_cache;
mnt_free_fs;
mnt_free_iter;
@@ -18,7 +17,6 @@ global:
mnt_free_optls;
mnt_free_tab;
mnt_fs_append_optstr;
- mnt_fs_fprintf;
mnt_fs_get_devno;
mnt_fs_get_freq;
mnt_fs_get_fs_optstr;
@@ -118,7 +116,6 @@ global:
mnt_tab_find_srcpath;
mnt_tab_find_tag;
mnt_tab_find_target;
- mnt_tab_fprintf;
mnt_tab_get_cache;
mnt_tab_get_name;
mnt_tab_get_nents;
diff --git a/shlibs/mount/src/tab.c b/shlibs/mount/src/tab.c
index 939e8c876..c61571d1c 100644
--- a/shlibs/mount/src/tab.c
+++ b/shlibs/mount/src/tab.c
@@ -652,90 +652,6 @@ mnt_fs *mnt_tab_find_source(mnt_tab *tb, const char *source, int direction)
return fs;
}
-
-/**
- * mnt_tab_fprintf:
- * @tb: tab pointer
- * @f: FILE
- * @fmt: per line printf-like format string (see MNT_TAB_PRINTFMT)
- *
- * Returns: 0 on success, -1 in case of error.
- */
-int mnt_tab_fprintf(mnt_tab *tb, FILE *f, const char *fmt)
-{
- mnt_iter itr;
- mnt_fs *fs;
-
- assert(f);
- assert(fmt);
- assert(tb);
-
- if (!f || !fmt || !tb)
- return -1;
-
- mnt_reset_iter(&itr, MNT_ITER_FORWARD);
- while(mnt_tab_next_fs(tb, &itr, &fs) == 0) {
- if (mnt_fs_fprintf(fs, f, fmt) == -1)
- return -1;
- }
-
- return 0;
-}
-
-/**
- * mnt_tab_update_file
- * @tb: tab pointer
- *
- * Writes tab to disk. Don't forget to lock the file (see mnt_lock()).
- *
- * Returns: 0 on success, -1 in case of error.
- */
-int mnt_tab_update_file(mnt_tab *tb, const char *filename)
-{
- FILE *f = NULL;
- char tmpname[PATH_MAX];
- struct stat st;
- int fd;
-
- assert(tb);
- if (!tb)
- goto error;
-
- if (snprintf(tmpname, sizeof(tmpname), "%s.tmp", filename)
- >= sizeof(tmpname))
- goto error;
-
- f = fopen(tmpname, "w");
- if (!f)
- goto error;
-
- if (mnt_tab_fprintf(tb, f, MNT_TAB_PRINTFMT) != 0)
- goto error;
-
- fd = fileno(f);
-
- if (fchmod(fd, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH) < 0)
- goto error;
-
- /* Copy uid/gid from the present file before renaming. */
- if (stat(filename, &st) == 0) {
- if (fchown(fd, st.st_uid, st.st_gid) < 0)
- goto error;
- }
-
- fclose(f);
- f = NULL;
-
- if (rename(tmpname, filename) < 0)
- goto error;
-
- return 0;
-error:
- if (f)
- fclose(f);
- return -1;
-}
-
#ifdef TEST_PROGRAM
static int parser_errcb(mnt_tab *tb, const char *filename, int line, int flag)
diff --git a/shlibs/mount/src/tab_parse.c b/shlibs/mount/src/tab_parse.c
index dc3486d53..4ab39fbd1 100644
--- a/shlibs/mount/src/tab_parse.c
+++ b/shlibs/mount/src/tab_parse.c
@@ -607,7 +607,8 @@ done:
* This function uses @uf to found corresponding record in @tb, then the record
* from @tb is updated (userspace specific mount options are added).
*
- * Note that @uf must contain userspace specific mount options only!
+ * Note that @uf must contain only userspace specific mount options instead of
+ * VFS options (note that FS options are ignored).
*
* Returns: modified filesystem (from @tb) or NULL.
*/