Messages in this thread |  | | | Date | Fri, 28 Nov 1997 14:06:55 +1100 (EST) | | From | Paul Wilkins <> | | Subject | FAT text conversion |
| |
Hi Folks, I know most of the kernel team don't really do DOS, but plenty of Linux users are often faced with the problem of opening text files on fat partitions, and hit the CR LF thing. I hit it all the time for text files, and when copying html from one partition to another.
The fat fs allows you to use the conv option to do a CR LF <--> CR conversion automatically, but if your not aware the option exists, it takes some time before you stumble across it in the man pages.
I've changed my own inode.c and misc.c slightly just to make the conversion a little easier. First, I've made conversion the default. I note the warning in the manpages about lseeks, but I'm not sure how big this problem really is. The other thing is that with the conv=auto option, it makes conversion the default, barring known binary files. To my mind, this should work the other way, seeing as conversion is a hazardous exercise. I'd like to see the "auto conversion" defaulting to _not_ converting, and performing the conversion for files with known text extensions (.txt, .htm, .c, .h, ,jav ...). Rather than changing the way "auto" works, I've created a new conv option, conv=[s]afe. I'm appending the patches below, which are pretty trivial.
I think it would be worthwhile to make this the default behaviour for a fat mount, so that newbies would initially not have to bother with conversions with their text files.
I would have written to the author of the fat fs directly, Werner Almesberger, but there's no email address in the source, and no mention of who currently supports it, so I'm posting here, hoping to get the changes incorporated into the code base.
Cheers
Paul
*** misc.c.dist Mon Oct 27 11:46:16 1997 --- misc.c Mon Oct 27 11:48:06 1997 *************** static char bin_extensions[] = *** 27,32 **** --- 27,39 ---- "GIF" "BMP" "TIF" "GL " "JPG" "PCX" /* graphics */ "TFM" "VF " "GF " "PK " "PXL" "DVI"; /* TeX */ + /* Well-known text file extensions - not so many of these */ + + static char txt_extensions[] = + "TXT" "HTM" /* text and html */ + "BAT" /* dos bat script */ + "C " "H " /* C source */ + "JAV"; /* Java source */ /* * fat_fs_panic reports a severe file system problem and sets the file system *************** int is_binary(char conversion,char *exte *** 65,70 **** --- 72,82 ---- for (walk = bin_extensions; *walk; walk += 3) if (!strncmp(extension,walk,3)) return 1; return 0; + case 's' : + for (walk = txt_extensions; *walk; walk += 3) + if (!strncmp(extension,walk,3)) return 0; + return 1; + default: printk("Invalid conversion mode - defaulting to " "binary.\n"); *** inode.c.dist Mon Oct 27 11:46:11 1997 --- inode.c Mon Oct 27 11:47:20 1997 *************** static int parse_options(char *options,i *** 91,97 **** char *this_char,*value; opts->name_check = 'n'; ! opts->conversion = 'b'; opts->fs_uid = current->uid; opts->fs_gid = current->gid; opts->fs_umask = current->fs->umask; --- 91,97 ---- char *this_char,*value; opts->name_check = 'n'; ! opts->conversion = 's'; opts->fs_uid = current->uid; opts->fs_gid = current->gid; opts->fs_umask = current->fs->umask; *************** static int parse_options(char *options,i *** 111,121 **** else return 0; } else if (!strcmp(this_char,"conv") && value) { ! if (value[0] && !value[1] && strchr("bta",*value)) opts->conversion = *value; else if (!strcmp(value,"binary")) opts->conversion = 'b'; else if (!strcmp(value,"text")) opts->conversion = 't'; else if (!strcmp(value,"auto")) opts->conversion = 'a'; else return 0; } else if (!strcmp(this_char,"dots")) { --- 111,122 ---- else return 0; } else if (!strcmp(this_char,"conv") && value) { ! if (value[0] && !value[1] && strchr("btas",*value)) opts->conversion = *value; else if (!strcmp(value,"binary")) opts->conversion = 'b'; else if (!strcmp(value,"text")) opts->conversion = 't'; else if (!strcmp(value,"auto")) opts->conversion = 'a'; + else if (!strcmp(value,"safe")) opts->conversion = 's'; else return 0; } else if (!strcmp(this_char,"dots")) {
------------------------------------------------------------------------------ ,--- Paul Wilkins | o o | Internet Operations Manager ` \_/ ' Linux TMP Worldwide /\___/\ The Choice of paulw@tmpw.com.au |_/ . \_| A GNU Generation http://www.monsterboard.com.au \_/___\_/ ------------------------------------------------------------------------------
|  |