Re: [patch] Re: getfsent(3) and spaces in fstab
imho - expensive algorithm... i want to see anything more simple... like gtok() instead es_strsep() + remove_escapes()? I have adopted my patch to use your neat gtok() function, but I came to the conclusion that a two-pass algorithm is necessary: The first pass detects whether a line from fstab is the old or the new style format (old style lines may only have unescaped white spaces before a trailing #-comment). Then, the second pass extracts the information. I admit this is rather complicated, but I don't how to handle two sets of delimiters (:\n and \n\r\t) with only one pass. Using gtok() to detect the style of line is not an option IMO, since it would convert escape sequences. Now, the following lines can be processed: 1) old style: file system:mount point:mount type:dump:passno([' ','\t']*#comment)* 2) new style format as described in fstab(5) + an optional #-comment at the end of the line 3) empty lines, white space lines, deliberately many white spaces + comment In both the old and the new style lines, white spaces can be written as escape sequences or in double quotes. Could somebody please review my patch - if there are no objections (but I am sure there are some more details that can be improved), I will write a PR in order Regards, Simon --- fstab.c.origFri Aug 1 17:18:00 2003 +++ fstab.c Thu Aug 7 15:46:39 2003 @@ -84,6 +84,60 @@ _fs_fstab.fs_spec = buf; } +/* + * Gets a token from a string *s, that is either empty or is separated by + * a set of delimiters *delim. + * Characters that are in *delim, can occur in the token if the are escaped, + * i.e. have a '\' prepended. The character '\' itself is encoded as '\\'. + * *s can have a trailing comment (indicated by a '#'), which will cause the + * characters after the '#' to be ignored. To encode a '#' within a token, + * use '\#'. + * + * If a token is found, gtok sets the last character after its end + * to '\0' and returns a pointer it. Otherwise the return value is NULL. + * As a side effect, the input string *s modified and points to the next + * character after the end of the current token, i.e. after the '\0'. + */ +char *gtok(char **s, char const *delim) +{ + int quoted, escaped; + static char const esc_set[] = { 't', 'r', 'n', 'a', 0 }; + static char const esc_rep[] = { '\t', '\r', '\n', '\a', 0 }; + char *tok, *r, *w, *p; + + if (!s || !*s || !*(tok = *s + strspn(*s, delim)) || *tok == '#') + return NULL; + + for (quoted = escaped = 0, r = w = tok; *r; r++) { + if (!escaped) { + if (*r == '\\') { + escaped = 1; + continue; + } + if (*r == '\') { + quoted ^= -1; + continue; + } + if (!quoted) { + if (strchr(delim, *r)) { + r++; + break; + } + } + } else { + escaped = 0; + if ((p = strchr(esc_set, *r)) != NULL) { + *w++ = esc_rep[p - esc_set]; + continue; + } + } + *w++ = *r; + } + *w = 0; + *s = r; + return tok; +} + static int fstabscan() { @@ -91,21 +145,73 @@ #defineMAXLINELENGTH 1024 static char line[MAXLINELENGTH]; char subline[MAXLINELENGTH]; - int typexx; + int typexx, escaped=0, quoted=0, ws_sep=0; for (;;) { if (!(p = fgets(line, sizeof(line), _fs_fp))) return(0); -/* OLD_STYLE_FSTAB */ ++LineNo; - if (*line == '#' || *line == '\n') - continue; - if (!strpbrk(p, \t)) { - _fs_fstab.fs_spec = strsep(p, :\n); - _fs_fstab.fs_file = strsep(p, :\n); + + /* Detect whether line is in old or new fstab style */ + for (cp=p; *cp != '\n'; ++cp) { + if (*cp == '\\') { + escaped = (escaped ? 0 : 1); + continue; + } + if (!escaped) { + /* Quotes */ + if (*cp == '\') { + quoted = (quoted ? 0 : 1); + continue; + } + if (quoted) + continue; + /* new white separator found */ + if (cp p strspn (cp, \n\r\t) + !strspn(cp-1, \t)) +
Re: [PR bin/55539] getfsent(3) and spaces in fstab
Could somebody please review my patch - if there are no objections (but I am sure there are some more details that can be improved), I will write a PR. I have filed a PR in order to preserve this patch. It can be found here: http://www.freebsd.org/cgi/query-pr.cgi?pr=55539 Regards, Simon signature.asc Description: Digital signature
Re: [patch] Re: getfsent(3) and spaces in fstab
On Mon, Aug 04, 2003 at 02:33:31AM +0200, Simon Barner wrote: Hi Terry, You need to add '\\' to the list of characters that can be escaped, or you've just traded the inability to specify '\t' or ' ' for an inability to speciy '\\'. Oh yes, I have overlook this special case. I revised my patch in order to get this right. Simon helo. imho - expensive algorithm... i want to see anything more simple... like gtok() instead es_strsep() + remove_escapes()? #include stdio.h #include stdlib.h #include string.h char *gtok(char **s, char const *delim) { int quoted, escaped; static char const esc_set[] = { 't', 'r', 'n', 'a', 0 }; static char const esc_rep[] = { '\t', '\r', '\n', '\a', 0 }; char *tok, *r, *w, *p; if (!s || !*s || !*(tok = *s + strspn(*s, delim)) || *tok == '#') return NULL; for (quoted = escaped = 0, r = w = tok; *r; r++) { if (!escaped) { if (*r == '\\') { escaped = 1; continue; } if (*r == '\') { quoted ^= -1; continue; } if (!quoted strchr(delim, *r)) { r++; break; } } else { escaped = 0; if ((p = strchr(esc_set, *r)) != NULL) { *w++ = esc_rep[p - esc_set]; continue; } } *w++ = *r; } *w = 0; *s = r; return tok; } #if 0 main() { char *s, *t, buf[0x1000]; while (fgets(buf, sizeof buf, stdin)) for (s = buf; t = gtok(s, \t\r\n); ) printf(\%s\\n, t); return 0; } #endif /swp --- fstab.c.orig Fri Aug 1 17:18:00 2003 +++ fstab.c Mon Aug 4 01:46:55 2003 @@ -49,6 +49,7 @@ #include errno.h #include fstab.h #include paths.h +#include stdbool.h #include stdio.h #include stdlib.h #include string.h @@ -84,6 +85,140 @@ _fs_fstab.fs_spec = buf; } +/* + * Get next token from string *stringp, where tokens are possibly-empty + * strings separated by characters from delim. + * + * Writes NULs into the string at *stringp to end tokens. + * delim need not remain constant from call to call. + * On return, *stringp points past the last NUL written (if there might + * be further tokens), or is NULL (if there are definitely no more tokens). + * + * If *stringp is NULL, es_strsep returns NULL. + * + * In contrast to strsep(3), es_strsep will allow escaped delimiters + * within a token. These escaped characters as well as the special case + * '\\' will be converted appropriately ('\delim' - 'delim, '\\' - '\' + * + */ +char * +es_strsep(char **stringp, const char *delim) +{ + boolescaped=false; + char*s, *t, *u; + int i; + + + if (*stringp == '\0') /* empty string */ + return NULL; + s = *stringp; + s += strspn (s, delim); /* skip delimiters */ + + if (*s == '\0') /* string consists only of delimiters */ + return NULL; + + /* + * skip a string consisting of non-delimiters, + * escapted delimiters or '\\' + */ + for (t = s; *t != '\0'; ++t) { + if (*t == '\\') { + if (escaped) { /* convert \\ to \ */ + --t; + u = t; + escaped = false; + while (u[0] != '\0') { + u[0] = u[1]; + ++u; + } + } else /* start \-Sequence */ + escaped = true; + continue; + } + + /* search for delimiter */ + for (i=0; delim[i] != '\0'; ++i) { + if (*t == delim[i]) + break; + } + + /* un-escaped delimiter found = end of token */ + if (!escaped delim[i] != '\0') + break; + + /* escaped delimiter found = remove / */ + if (escaped) { + --t; + u = t; +escaped = false; + while (u[0] != '\0') { + u[0] = u[1]; + ++u; + } + } + } + + if (*t != '\0') { + *t = '\0'; /* end current token */ + *stringp = t+1; /* *t != '\0' = *(t+1) is valid */ + } else + *stringp = 0; /* end of string reached */
Re: getfsent(3) and spaces in fstab
On Tue, 2003-08-05 at 11:05, Simon Barner wrote: Hi, Check PR 37569: This bugged the hell out of me also, so I created a patch to allow enclosing the device name in quotes. The PR was logged over a year ago: I can't remember the details, but the source has been sitting silently in my tree and working since then. Whatever way the problem is resolved, can someone close the PR? I can't believe it... I have searched the PR database, Google, etc. for existing solutions to this problem, but I did not find yours. I also considered using quotes, but since you need escape-sequences to encode quotes in your solution, too, the approach using '\ ', '\TAB', '\\' is simpler and cleaner IMHO. Simon I find the quotes approach produces more readable (and manageable) fstabs, but I don't care about that sufficiently to argue further :-). Anything that addresses the problem and can close the PR will suit me! ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: getfsent(3) and spaces in fstab
Hi, Check PR 37569: This bugged the hell out of me also, so I created a patch to allow enclosing the device name in quotes. The PR was logged over a year ago: I can't remember the details, but the source has been sitting silently in my tree and working since then. Whatever way the problem is resolved, can someone close the PR? I can't believe it... I have searched the PR database, Google, etc. for existing solutions to this problem, but I did not find yours. I also considered using quotes, but since you need escape-sequences to encode quotes in your solution, too, the approach using '\ ', '\TAB', '\\' is simpler and cleaner IMHO. Simon signature.asc Description: Digital signature
Re: getfsent(3) and spaces in fstab
Hi, Check PR 37569: This bugged the hell out of me also, so I created a patch to allow enclosing the device name in quotes. The PR was logged over a year ago: I can't remember the details, but the source has been sitting silently in my tree and working since then. Whatever way the problem is resolved, can someone close the PR? On Wed, 2003-07-30 at 23:45, Simon Barner wrote: Hi -hackers, discussing some modifications for the sysutils/linneighborhood port, Heiner Eichmann and me came across the following problem: getfsent(3) will fail, if the name of the file system or the mount point contains whitespaces, be them escaped or not (file system names with spaces occur quite of with smbfs mounts). I searched the mail archives and the PR data base, but apart from this email here http://freebsd.rambler.ru/bsdmail/freebsd-questions_2003/msg05947.html this problem seems to be either unknown or rather well-known but accepted. I know there is workaround which is to create symbolic links for the paths that contain spaces, but to my mind this is not a real solution. Before taking any further action: Do file system names and mount points with whitespaces violate the specification of fstab? If so, the least thing I'd suggest is the document this restriction. Or should one extend 'getfsent' such that is able to cope with those whitespaces? I am not sure whether this would have any further implications so I am asking here. Cheers, Simon ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: [patch] Re: getfsent(3) and spaces in fstab
Hi Terry, You need to add '\\' to the list of characters that can be escaped, or you've just traded the inability to specify '\t' or ' ' for an inability to speciy '\\'. Oh yes, I have overlook this special case. I revised my patch in order to get this right. Simon --- fstab.c.origFri Aug 1 17:18:00 2003 +++ fstab.c Mon Aug 4 01:46:55 2003 @@ -49,6 +49,7 @@ #include errno.h #include fstab.h #include paths.h +#include stdbool.h #include stdio.h #include stdlib.h #include string.h @@ -84,6 +85,140 @@ _fs_fstab.fs_spec = buf; } +/* + * Get next token from string *stringp, where tokens are possibly-empty + * strings separated by characters from delim. + * + * Writes NULs into the string at *stringp to end tokens. + * delim need not remain constant from call to call. + * On return, *stringp points past the last NUL written (if there might + * be further tokens), or is NULL (if there are definitely no more tokens). + * + * If *stringp is NULL, es_strsep returns NULL. + * + * In contrast to strsep(3), es_strsep will allow escaped delimiters + * within a token. These escaped characters as well as the special case + * '\\' will be converted appropriately ('\delim' - 'delim, '\\' - '\' + * + */ +char * +es_strsep(char **stringp, const char *delim) +{ + boolescaped=false; + char*s, *t, *u; + int i; + + + if (*stringp == '\0') /* empty string */ + return NULL; + s = *stringp; + s += strspn (s, delim); /* skip delimiters */ + + if (*s == '\0') /* string consists only of delimiters */ + return NULL; + + /* +* skip a string consisting of non-delimiters, +* escapted delimiters or '\\' + */ + for (t = s; *t != '\0'; ++t) { + if (*t == '\\') { + if (escaped) { /* convert \\ to \ */ + --t; + u = t; + escaped = false; + while (u[0] != '\0') { + u[0] = u[1]; + ++u; + } + } else /* start \-Sequence */ + escaped = true; + continue; + } + + /* search for delimiter */ + for (i=0; delim[i] != '\0'; ++i) { + if (*t == delim[i]) + break; + } + + /* un-escaped delimiter found = end of token */ + if (!escaped delim[i] != '\0') + break; + + /* escaped delimiter found = remove / */ + if (escaped) { + --t; + u = t; +escaped = false; + while (u[0] != '\0') { + u[0] = u[1]; + ++u; + } + } + } + + if (*t != '\0') { + *t = '\0'; /* end current token */ + *stringp = t+1; /* *t != '\0' = *(t+1) is valid */ + } else + *stringp = 0; /* end of string reached */ + + return s; /* return current token */ +} + +/* + * This function converts escaped characters: + * '\delim' - 'delim', '\\' - '\' + * + * If there are unescaped delimiters, 'false' will be return to indicate + * an error, otherwise remove_escape returns 'true'. + */ +bool remove_escapes (char **s, const char* delim) { + boolescaped=false; + char*t, *u; + int i; + + for (t = *s; *t != '\0'; ++t) { + if (*t == '\\') { + if (escaped) { /* convert \\ to \ */ + --t; + u = t; + escaped = false; + while (u[0] != '\0') { + u[0] = u[1]; + ++u; + } + } else /* start \-Sequence */ + escaped = true; + continue; + } + + /* search for delimiter */ + for (i=0; delim[i] != '\0'; ++i) { + if (*t == delim[i]) + break; + } + + /* un-escaped delimiter found = error */ + if (!escaped delim[i] != '\0') + return false; + + /* escaped delimiter found = remove / */ + if (escaped) { + --t; + u = t; +escaped = false; + while (u[0] != '\0') { + u[0] = u[1]; + ++u; + } + } + } + + return true; +} + static int
Re: [patch] Re: getfsent(3) and spaces in fstab
Simon Barner wrote: The attached patch will allow blanks and tabs for file systems and path names, as long as the are protected by a '\'. For the old fstab style, blanks and tabs are not allowed as delimiters (as it was in the old implementation). You need to add '\\' to the delimited list, so that it is not skipped. You need to add '\\' to the list of characters that can be escaped, or you've just traded the inability to specify '\t' or ' ' for an inability to speciy '\\'. -- Terry ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: getfsent(3) and spaces in fstab
Chris BeHanna wrote: What about test%201/mnt/test%201 ufs ro 0 0 ? Ugly, yes, but that's how a lot of tools escape spaces. % is almost infinitely more likely in a path than \; better to use the \ than the % mechanism. Also, the parser can b LALR single token lookahead, wheras % rewuires pushing state (2 token lookahead). -- Terry ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
[patch] Re: getfsent(3) and spaces in fstab
Hi, For all the 'good rules' of orthonogolity and consistency etc it is a good thing, however I still feel that at the level of the fstab where you are mounting entire file system trees, the simplest naming formats are probably the best. A philosophical point only, but it would keep the fstab format minimalistic and clean. This point of view could probably be stated in the man page once the '\ ' form is implemented, as a suggested practice. Yes, you are definitely right with this point, and I aggree that such a hint should be added to the fstab(5) man page. But as somebody else pointed out, one of FreeBSD's advantages is its interoperability with other systems, and this was one of the reasons why I decided to extent 'getfsent'. The attached patch will allow blanks and tabs for file systems and path names, as long as the are protected by a '\'. For the old fstab style, blanks and tabs are not allowed as delimiters (as it was in the old implementation). Thus /foo\ bar:/mnt\ point:ufs is a valid old-style fstab entry, while /foo\ bar:/mnt\ point:ufs /foo\ bar :/mnt\ point:ufs etc. are not. For the current fstab style, unescaped blanks and tabs are handled as delimiters. Simon --- fstab.c.origFri Aug 1 17:18:00 2003 +++ fstab.c Fri Aug 1 17:17:46 2003 @@ -84,6 +84,78 @@ _fs_fstab.fs_spec = buf; } +/* + * Get next token from string *stringp, where tokens are possibly-empty + * strings separated by characters from delim. + * + * Writes NULs into the string at *stringp to end tokens. + * delim need not remain constant from call to call. + * On return, *stringp points past the last NUL written (if there might + * be further tokens), or is NULL (if there are definitely no more tokens). + * + * If *stringp is NULL, es_strsep returns NULL. + * + * In contrast to strsep(3), es_strsep will allow escaped delimiters + * within a token. + */ +char * +es_strsep(char **stringp, const char *delim) +{ + char*s, *t; + size_t n; + + if (*stringp == '\0') /* empty string */ + return NULL; + s = *stringp; + s += strspn (s, delim); /* skip delimiters */ + + if (*s == '\0') /* string consists only of delimiters */ + return NULL; + + /* skip a string consisting of non-delimiters or escapted delimiters */ + t = s; + for (;;) { + /* skip non-delimiters */ + n = strcspn (t, delim); + if (n == 0) /* delimiters found - end of token */ + break; + t += n; + if (*t == '\0') /* end of string reached */ + break; + + /* skip escaped delimiters */ + if (*(t-1) == '\\') /* n != 0 = *(t-1) is valid */ + ++t; + if (*t == '\0') /* end of string reached */ + break; + } + + if (*t != '\0') { + *t = '\0'; /* end current token */ + *stringp = t+1; /* *t != '\0' = *(t+1) is valid */ + } else + *stringp = 0; /* end of string reached */ + + return s; /* return current token */ +} + +/* + * This function removes all '\' characters from a string. + * + * It will NOT handle escape sequences as '\t' or '\n'! + */ +void +remove_escapes (char **s) { + char *p = *s, *q; + while ((p = strchr (p, '\\')) != 0) { + q = p; + while (q[0] != '\0') { + q[0] = q[1]; + ++q; + } + } +} + static int fstabscan() { @@ -101,9 +173,17 @@ ++LineNo; if (*line == '#' || *line == '\n') continue; - if (!strpbrk(p, \t)) { + + /* escapted white-spaces only are allowed in old-style format */ + cp = p; + while ((cp = strpbrk(cp, \t)) != 0 + cp != p cp[-1] == '\\') + ++cp; + if (cp == 0) { _fs_fstab.fs_spec = strsep(p, :\n); + remove_escapes (_fs_fstab.fs_spec); _fs_fstab.fs_file = strsep(p, :\n); + remove_escapes (_fs_fstab.fs_file); fixfsfile(); _fs_fstab.fs_type = strsep(p, :\n); if (_fs_fstab.fs_type) { @@ -124,14 +204,18 @@ goto bad; } /* OLD_STYLE_FSTAB */ - while ((cp = strsep(p, \t\n)) != NULL *cp == '\0') + while ((cp = es_strsep(p, \t\n)) != NULL *cp == '\0') ; _fs_fstab.fs_spec = cp; + remove_escapes (_fs_fstab.fs_spec); if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') continue; -
Re: getfsent(3) and spaces in fstab
Hi, This very discussion came up in -questions a few months ago (or maybe it was late last year). The conclusion was that unless someone rewrites the /etc/fstab parsing routines in libc to support quoted and/or escaped spaces, we'll never be able to mount filesystems that have spaces in their names. I volunteer for that. My intention is to make getfsent(3) recognize '\ ' for both the filesystem and the mount point. I think this is more applicable than using quotes. 'mount' should already handle this correctly, but I will do thorough testing, of course. Cheers, Simon signature.asc Description: Digital signature
Re: getfsent(3) and spaces in fstab
For all the 'good rules' of orthonogolity and consistency etc it is a good thing, however I still feel that at the level of the fstab where you are mounting entire file system trees, the simplest naming formats are probably the best. A philosophical point only, but it would keep the fstab format minimalistic and clean. This point of view could probably be stated in the man page once the '\ ' form is implemented, as a suggested practice. another 0.02c mjt On Thu, 2003-07-31 at 13:43, Simon Barner wrote: Hi, This very discussion came up in -questions a few months ago (or maybe it was late last year). The conclusion was that unless someone rewrites the /etc/fstab parsing routines in libc to support quoted and/or escaped spaces, we'll never be able to mount filesystems that have spaces in their names. I volunteer for that. My intention is to make getfsent(3) recognize '\ ' for both the filesystem and the mount point. I think this is more applicable than using quotes. 'mount' should already handle this correctly, but I will do thorough testing, of course. Cheers, Simon This Email has been scanned for Viruses by MailMarshal. -- Murray Taylor Special Projects Engineer - Bytecraft Systems Entertainment P: +61 3 8710 2555 F: +61 3 8710 2599 D: +61 3 9238 4275 M: +61 417 319 256 E: [EMAIL PROTECTED] or visit us on the web http://www.bytecraftsystems.com http://www.bytecraftentertainment.com This Email has been scanned for Viruses by MailMarshal. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: getfsent(3) and spaces in fstab
On Thu, 31 Jul 2003, Simon Barner wrote: Just a thort, not having tried it .. does either of the 'standard' methods of including spaces actually work in fstab ?? I speak of quoting (either single or double) and backslashing the space /mnt/space/silly long dirname/filename also with spaces or /mnt/space/silly\ long\ dirname/filename\ also\ with\ spaces Sorry, I should have written that I have performed tests: Here is what I did: test\ 1 /mnt/test\ 1ufs ro 0 0 'test 2''/mnt/test 2' ufs ro 0 0 test 3/mnt/test 3 ufs ro 0 0 This test program [...snipped...] Gives me the following output: fstab: /etc/fstab:14: Inappropriate file type or format fstab: /etc/fstab:15: Inappropriate file type or format fstab: /etc/fstab:16: Inappropriate file type or format What about test%201/mnt/test%201 ufs ro 0 0 ? Ugly, yes, but that's how a lot of tools escape spaces. -- Chris BeHanna Software Engineer (Remove bogus before responding.) [EMAIL PROTECTED] Turning coffee into software since 1990. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: getfsent(3) and spaces in fstab
At 10:16 PM -0400 7/31/03, Chris BeHanna wrote: Sorry, I should have written that I have performed tests: Here is what I did: test\ 1 /mnt/test\ 1ufs ro 0 0 'test 2''/mnt/test 2' ufs ro 0 0 test 3/mnt/test 3 ufs ro 0 0 [...etc...] What about test%201/mnt/test%201 ufs ro 0 0 ? Ugly, yes, but that's how a lot of tools escape spaces. There may be people who already mount directories with %'s in them. If you wanted to be fancy, there could be some kind of trigger that says after this point, recognize URL-style escaping rules. -- Garance Alistair Drosehn= [EMAIL PROTECTED] Senior Systems Programmer or [EMAIL PROTECTED] Rensselaer Polytechnic Instituteor [EMAIL PROTECTED] ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: getfsent(3) and spaces in fstab
On Thu, 31 Jul 2003, Chris BeHanna wrote: What about test%201/mnt/test%201 ufs ro 0 0 ? Ugly, yes, but that's how a lot of tools escape spaces. Just FYI, here is how Linux handles this (from fstab(5)): The second field, (fs_file), describes the mount point for the filesys- tem. For swap partitions, this field should be specified as `none'. If the name of the mount point contains spaces these can be escaped as `\040'. It might be a good idea to use this method rather than inventing a new one. -- Tod McQuillin ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
getfsent(3) and spaces in fstab
Hi -hackers, discussing some modifications for the sysutils/linneighborhood port, Heiner Eichmann and me came across the following problem: getfsent(3) will fail, if the name of the file system or the mount point contains whitespaces, be them escaped or not (file system names with spaces occur quite of with smbfs mounts). I searched the mail archives and the PR data base, but apart from this email here http://freebsd.rambler.ru/bsdmail/freebsd-questions_2003/msg05947.html this problem seems to be either unknown or rather well-known but accepted. I know there is workaround which is to create symbolic links for the paths that contain spaces, but to my mind this is not a real solution. Before taking any further action: Do file system names and mount points with whitespaces violate the specification of fstab? If so, the least thing I'd suggest is the document this restriction. Or should one extend 'getfsent' such that is able to cope with those whitespaces? I am not sure whether this would have any further implications so I am asking here. Cheers, Simon signature.asc Description: Digital signature
Re: getfsent(3) and spaces in fstab
From the man page Each filesystem is described on a separate line; fields on each line are separated by tabs or spaces. Clearly, having a space in a filesystem or mount point will violate this constraint, by causing the trailing part to become the next field. Given that this is such a fundamental level in the scheme of things may I suggest that the fstab and mount points maintain the no spaces rule, and allow the higher filesystem (and particularly windoze noddies using SAMBA file shares) to cope with the spaces in filenames stuff.. 0.02c mjt Yes I have a large SAMBA system for the users and Yes a lot of their directories and filenames are 'space laden' On Wed, 2003-07-30 at 22:45, Simon Barner wrote: Hi -hackers, discussing some modifications for the sysutils/linneighborhood port, Heiner Eichmann and me came across the following problem: getfsent(3) will fail, if the name of the file system or the mount point contains whitespaces, be them escaped or not (file system names with spaces occur quite of with smbfs mounts). I searched the mail archives and the PR data base, but apart from this email here http://freebsd.rambler.ru/bsdmail/freebsd-questions_2003/msg05947.html this problem seems to be either unknown or rather well-known but accepted. I know there is workaround which is to create symbolic links for the paths that contain spaces, but to my mind this is not a real solution. Before taking any further action: Do file system names and mount points with whitespaces violate the specification of fstab? If so, the least thing I'd suggest is the document this restriction. Or should one extend 'getfsent' such that is able to cope with those whitespaces? I am not sure whether this would have any further implications so I am asking here. Cheers, Simon This Email has been scanned for Viruses by MailMarshal. -- Murray Taylor Special Projects Engineer - Bytecraft Systems Entertainment P: +61 3 8710 2555 F: +61 3 8710 2599 D: +61 3 9238 4275 M: +61 417 319 256 E: [EMAIL PROTECTED] or visit us on the web http://www.bytecraftsystems.com http://www.bytecraftentertainment.com This Email has been scanned for Viruses by MailMarshal. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: getfsent(3) and spaces in fstab
Do file system names and mount points with whitespaces violate the specification of fstab? If so, the least thing I'd suggest is the document this restriction. Or should one extend 'getfsent' such that is able to cope with those whitespaces? I am not sure whether this would have any further implications so I am asking here. Formal standards tend to avoid system administration issues such as this. I doubt you would be violating any published standard. I say go for it. If something else breaks because of this change, let's fix that, too. I like the fact that FreeBSD works pretty well with other systems; lets keep pushing that. Tim Kientzle ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: getfsent(3) and spaces in fstab
Just a thort, not having tried it .. does either of the 'standard' methods of including spaces actually work in fstab ?? I speak of quoting (either single or double) and backslashing the space /mnt/space/silly long dirname/filename also with spaces or /mnt/space/silly\ long\ dirname/filename\ also\ with\ spaces mjt On Wed, 2003-07-30 at 23:31, Tim Kientzle wrote: Do file system names and mount points with whitespaces violate the specification of fstab? If so, the least thing I'd suggest is the document this restriction. Or should one extend 'getfsent' such that is able to cope with those whitespaces? I am not sure whether this would have any further implications so I am asking here. Formal standards tend to avoid system administration issues such as this. I doubt you would be violating any published standard. I say go for it. If something else breaks because of this change, let's fix that, too. I like the fact that FreeBSD works pretty well with other systems; lets keep pushing that. Tim Kientzle This Email has been scanned for Viruses by MailMarshal. -- Murray Taylor Special Projects Engineer - Bytecraft Systems Entertainment P: +61 3 8710 2555 F: +61 3 8710 2599 D: +61 3 9238 4275 M: +61 417 319 256 E: [EMAIL PROTECTED] or visit us on the web http://www.bytecraftsystems.com http://www.bytecraftentertainment.com This Email has been scanned for Viruses by MailMarshal. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]
Re: getfsent(3) and spaces in fstab
Just a thort, not having tried it .. does either of the 'standard' methods of including spaces actually work in fstab ?? I speak of quoting (either single or double) and backslashing the space /mnt/space/silly long dirname/filename also with spaces or /mnt/space/silly\ long\ dirname/filename\ also\ with\ spaces Sorry, I should have written that I have performed tests: Here is what I did: test\ 1 /mnt/test\ 1ufs ro 0 0 'test 2''/mnt/test 2' ufs ro 0 0 test 3/mnt/test 3 ufs ro 0 0 This test program --- snip -- #include fstab.h int main (int argc, char *argv[]) { struct fstab *f; while (0 != (f = getfsent ())) { printf (%s %s %s\n, f-fs_spec, f-fs_file, f-fs_vfstype); } return 0; } --- snip -- Gives me the following output: /dev/ad0s2b none swap /dev/ad0s1a / ufs /dev/ad0s2g /usr ufs /dev/ad0s2f /home ufs /dev/ad0s2e /var ufs /dev/vinum/mucke /samba-export ufs /dev/acd0c /mnt/cdrom cd9660 /dev/fd0.1440 /mnt/floppy msdos proc /proc procfs kern /kern kernfs linproc /compat/linux/proc linprocfs fstab: /etc/fstab:14: Inappropriate file type or format fstab: /etc/fstab:15: Inappropriate file type or format fstab: /etc/fstab:16: Inappropriate file type or format Simon signature.asc Description: Digital signature
Re: getfsent(3) and spaces in fstab
No, none of these methods will work. This very discussion came up in -questions a few months ago (or maybe it was late last year). The conclusion was that unless someone rewrites the /etc/fstab parsing routines in libc to support quoted and/or escaped spaces, we'll never be able to mount filesystems that have spaces in their names. -- Matt Emmerton Just a thort, not having tried it .. does either of the 'standard' methods of including spaces actually work in fstab ?? I speak of quoting (either single or double) and backslashing the space /mnt/space/silly long dirname/filename also with spaces or /mnt/space/silly\ long\ dirname/filename\ also\ with\ spaces mjt On Wed, 2003-07-30 at 23:31, Tim Kientzle wrote: Do file system names and mount points with whitespaces violate the specification of fstab? If so, the least thing I'd suggest is the document this restriction. Or should one extend 'getfsent' such that is able to cope with those whitespaces? I am not sure whether this would have any further implications so I am asking here. Formal standards tend to avoid system administration issues such as this. I doubt you would be violating any published standard. I say go for it. If something else breaks because of this change, let's fix that, too. I like the fact that FreeBSD works pretty well with other systems; lets keep pushing that. Tim Kientzle This Email has been scanned for Viruses by MailMarshal. -- Murray Taylor Special Projects Engineer - Bytecraft Systems Entertainment P: +61 3 8710 2555 F: +61 3 8710 2599 D: +61 3 9238 4275 M: +61 417 319 256 E: [EMAIL PROTECTED] or visit us on the web http://www.bytecraftsystems.com http://www.bytecraftentertainment.com This Email has been scanned for Viruses by MailMarshal. ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED] ___ [EMAIL PROTECTED] mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to [EMAIL PROTECTED]