aboutsummaryrefslogtreecommitdiff
path: root/sbin/fsck/fsck.c
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2003-04-25 01:12:35 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2003-04-25 01:12:35 +0000
commit8235d79a86b1db9f4e75fe78d2904e0ef04a906e (patch)
tree41c3a9d908c2174bed0fdf5812304039f4e98d8b /sbin/fsck/fsck.c
parent913fc94d2be3bdabc2c581825f94e9343745040c (diff)
downloadsrc-8235d79a86b1db9f4e75fe78d2904e0ef04a906e.tar.gz
src-8235d79a86b1db9f4e75fe78d2904e0ef04a906e.zip
Back out previous delta to fix fsck on filesystems without an fstab entry,
where we want to take the disklabel filesystem type of "4.2BSD" and use fsck_4.2bsd on those filesystems. Add a comment about why the code is there, now that we know: * XXX This is a kludge to make automatic filesystem type guessing * from the disklabel work for "4.2BSD" filesystems. It does a * very limited subset of transliteration to a normalised form of * filesystem name, and we do not seem to enforce a filesystem * name character set.
Notes
Notes: svn path=/head/; revision=113994
Diffstat (limited to 'sbin/fsck/fsck.c')
-rw-r--r--sbin/fsck/fsck.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c
index b483a9bb3bba..35a4b91d64f6 100644
--- a/sbin/fsck/fsck.c
+++ b/sbin/fsck/fsck.c
@@ -278,7 +278,7 @@ isok(struct fstab *fs)
static int
-checkfs(const char *vfstype, const char *spec, const char *mntpt,
+checkfs(const char *pvfstype, const char *spec, const char *mntpt,
char *auxopt, pid_t *pidp)
{
/* List of directories containing fsck_xxx subcommands. */
@@ -291,6 +291,7 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt,
pid_t pid;
int argc, i, status, maxargc;
char *optbuf, execname[MAXPATHLEN + 1], execbase[MAXPATHLEN];
+ char *vfstype = NULL;
const char *extra = NULL;
#ifdef __GNUC__
@@ -298,6 +299,24 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt,
(void) &optbuf;
(void) &vfstype;
#endif
+ /*
+ * We convert the vfstype to lowercase and any spaces to underscores
+ * to not confuse the issue
+ *
+ * XXX This is a kludge to make automatic filesystem type guessing
+ * from the disklabel work for "4.2BSD" filesystems. It does a
+ * very limited subset of transliteration to a normalised form of
+ * filesystem name, and we do not seem to enforce a filesystem
+ * name character set.
+ */
+ vfstype = strdup(pvfstype);
+ if (vfstype == NULL)
+ perror("strdup(pvfstype)");
+ for (i = 0; i < strlen(vfstype); i++) {
+ vfstype[i] = tolower(vfstype[i]);
+ if (vfstype[i] == ' ')
+ vfstype[i] = '_';
+ }
extra = getoptions(vfstype);
optbuf = NULL;
@@ -334,6 +353,7 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt,
warn("vfork");
if (optbuf)
free(optbuf);
+ free(vfstype);
return (1);
case 0: /* Child. */
@@ -367,6 +387,8 @@ checkfs(const char *vfstype, const char *spec, const char *mntpt,
if (optbuf)
free(optbuf);
+ free(vfstype);
+
if (pidp) {
*pidp = pid;
return 0;