diff options
Diffstat (limited to 'shlibs/mount/src/fs.c')
-rw-r--r-- | shlibs/mount/src/fs.c | 112 |
1 files changed, 0 insertions, 112 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 |