Date: Sun, 21 Oct 2012 12:01:11 +0000 (UTC) From: Ulrich Spoerlein <uqs@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r241806 - in head/sbin: fsck fsck_msdosfs Message-ID: <201210211201.q9LC1B5S068529@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: uqs Date: Sun Oct 21 12:01:11 2012 New Revision: 241806 URL: http://svn.freebsd.org/changeset/base/241806 Log: sbin/fsck: s/perror/perr/ to avoid shadowing - rename some other vars too - merge NetBSD license changes Obtained from: NetBSD PR: bin/139802 Reviewed by: ed Modified: head/sbin/fsck/fsck.c head/sbin/fsck/fsutil.c head/sbin/fsck/fsutil.h head/sbin/fsck/preen.c head/sbin/fsck_msdosfs/boot.c head/sbin/fsck_msdosfs/check.c head/sbin/fsck_msdosfs/dir.c head/sbin/fsck_msdosfs/fat.c Modified: head/sbin/fsck/fsck.c ============================================================================== --- head/sbin/fsck/fsck.c Sun Oct 21 11:52:16 2012 (r241805) +++ head/sbin/fsck/fsck.c Sun Oct 21 12:01:11 2012 (r241806) @@ -1,4 +1,4 @@ -/* $NetBSD: fsck.c,v 1.21 1999/04/22 04:20:53 abs Exp $ */ +/* $NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -13,11 +13,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -35,7 +31,7 @@ * * From: @(#)mount.c 8.19 (Berkeley) 4/19/94 * From: $NetBSD: mount.c,v 1.24 1995/11/18 03:34:29 cgd Exp - * $NetBSD: fsck.c,v 1.21 1999/04/22 04:20:53 abs Exp $ + * $NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $ */ #include <sys/cdefs.h> @@ -315,7 +311,7 @@ checkfs(const char *pvfstype, const char */ vfstype = strdup(pvfstype); if (vfstype == NULL) - perror("strdup(pvfstype)"); + perr("strdup(pvfstype)"); for (i = 0; i < strlen(vfstype); i++) { vfstype[i] = tolower(vfstype[i]); if (vfstype[i] == ' ') @@ -502,7 +498,7 @@ catopt(char **sp, const char *o) static void -mangle(char *options, int *argcp, const char ***argvp, int *maxargcp) +mangle(char *opts, int *argcp, const char ***argvp, int *maxargcp) { char *p, *s; int argc, maxargc; @@ -512,7 +508,7 @@ mangle(char *options, int *argcp, const argv = *argvp; maxargc = *maxargcp; - for (s = options; (p = strsep(&s, ",")) != NULL;) { + for (s = opts; (p = strsep(&s, ",")) != NULL;) { /* Always leave space for one more argument and the NULL. */ if (argc >= maxargc - 3) { maxargc <<= 1; Modified: head/sbin/fsck/fsutil.c ============================================================================== --- head/sbin/fsck/fsutil.c Sun Oct 21 11:52:16 2012 (r241805) +++ head/sbin/fsck/fsutil.c Sun Oct 21 12:01:11 2012 (r241806) @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.c,v 1.7 1998/07/30 17:41:03 thorpej Exp $ */ +/* $NetBSD: fsutil.c,v 1.15 2006/06/05 16:52:05 christos Exp $ */ /* * Copyright (c) 1990, 1993 @@ -12,7 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -31,7 +31,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fsutil.c,v 1.7 1998/07/30 17:41:03 thorpej Exp $"); +__RCSID("$NetBSD: fsutil.c,v 1.15 2006/06/05 16:52:05 christos Exp $"); #endif /* not lint */ __FBSDID("$FreeBSD$"); @@ -110,9 +110,13 @@ pwarn(const char *fmt, ...) } void -perror(const char *s) +perr(const char *fmt, ...) { - pfatal("%s (%s)", s, strerror(errno)); + va_list ap; + + va_start(ap, fmt); + vmsg(1, fmt, ap); + va_end(ap); } void @@ -132,18 +136,15 @@ devcheck(const char *origname) struct stat stslash, stchar; if (stat("/", &stslash) < 0) { - perror("/"); - printf("Can't stat root\n"); + perr("Can't stat `/'"); return (origname); } if (stat(origname, &stchar) < 0) { - perror(origname); - printf("Can't stat %s\n", origname); + perr("Can't stat %s\n", origname); return (origname); } if (!S_ISCHR(stchar.st_mode)) { - perror(origname); - printf("%s is not a char device\n", origname); + perr("%s is not a char device\n", origname); } return (origname); } @@ -156,7 +157,7 @@ getmntpt(const char *name) { struct stat devstat, mntdevstat; char device[sizeof(_PATH_DEV) - 1 + MNAMELEN]; - char *devname; + char *dev_name; struct statfs *mntbuf, *statfsp; int i, mntsize, isdev; @@ -169,10 +170,10 @@ getmntpt(const char *name) mntsize = getmntinfo(&mntbuf, MNT_NOWAIT); for (i = 0; i < mntsize; i++) { statfsp = &mntbuf[i]; - devname = statfsp->f_mntfromname; - if (*devname != '/') { + dev_name = statfsp->f_mntfromname; + if (*dev_name != '/') { strcpy(device, _PATH_DEV); - strcat(device, devname); + strcat(device, dev_name); strcpy(statfsp->f_mntfromname, device); } if (isdev == 0) { @@ -180,7 +181,7 @@ getmntpt(const char *name) continue; return (statfsp); } - if (stat(devname, &mntdevstat) == 0 && + if (stat(dev_name, &mntdevstat) == 0 && mntdevstat.st_rdev == devstat.st_rdev) return (statfsp); } Modified: head/sbin/fsck/fsutil.h ============================================================================== --- head/sbin/fsck/fsutil.h Sun Oct 21 11:52:16 2012 (r241805) +++ head/sbin/fsck/fsutil.h Sun Oct 21 12:01:11 2012 (r241806) @@ -1,4 +1,4 @@ -/* $NetBSD: fsutil.h,v 1.4 1998/07/26 20:02:36 mycroft Exp $ */ +/* $NetBSD: fsutil.h,v 1.114 2009/10/21 01:07:46 snj Exp $ */ /* * Copyright (c) 1996 Christos Zoulas. All rights reserved. @@ -11,11 +11,6 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christos Zoulas. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES @@ -31,9 +26,9 @@ * $FreeBSD$ */ -void perror(const char *); void pfatal(const char *, ...) __printflike(1, 2); void pwarn(const char *, ...) __printflike(1, 2); +void perr(const char *, ...) __printflike(1, 2); void panic(const char *, ...) __dead2 __printflike(1, 2); const char *devcheck(const char *); const char *cdevname(void); Modified: head/sbin/fsck/preen.c ============================================================================== --- head/sbin/fsck/preen.c Sun Oct 21 11:52:16 2012 (r241805) +++ head/sbin/fsck/preen.c Sun Oct 21 12:01:11 2012 (r241806) @@ -295,19 +295,19 @@ printpart(void) static void -addpart(const char *type, const char *devname, const char *mntpt) +addpart(const char *type, const char *dev, const char *mntpt) { - struct diskentry *d = finddisk(devname); + struct diskentry *d = finddisk(dev); struct partentry *p; TAILQ_FOREACH(p, &d->d_part, p_entries) - if (strcmp(p->p_devname, devname) == 0) { - warnx("%s in fstab more than once!\n", devname); + if (strcmp(p->p_devname, dev) == 0) { + warnx("%s in fstab more than once!\n", dev); return; } p = emalloc(sizeof(*p)); - p->p_devname = estrdup(devname); + p->p_devname = estrdup(dev); p->p_mntpt = estrdup(mntpt); p->p_type = estrdup(type); Modified: head/sbin/fsck_msdosfs/boot.c ============================================================================== --- head/sbin/fsck_msdosfs/boot.c Sun Oct 21 11:52:16 2012 (r241805) +++ head/sbin/fsck_msdosfs/boot.c Sun Oct 21 12:01:11 2012 (r241806) @@ -26,7 +26,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: boot.c,v 1.9 2003/07/24 19:25:46 ws Exp $"); +__RCSID("$NetBSD: boot.c,v 1.11 2006/06/05 16:51:18 christos Exp "); static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ @@ -49,7 +49,7 @@ readboot(int dosfs, struct bootblock *bo int i; if (read(dosfs, block, sizeof block) != sizeof block) { - perror("could not read boot block"); + perr("could not read boot block"); return FSFATAL; } @@ -103,7 +103,7 @@ readboot(int dosfs, struct bootblock *bo if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET) != boot->bpbFSInfo * boot->bpbBytesPerSec || read(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) { - perror("could not read fsinfo block"); + perr("could not read fsinfo block"); return FSFATAL; } if (memcmp(fsinfo, "RRaA", 4) @@ -131,7 +131,7 @@ readboot(int dosfs, struct bootblock *bo != boot->bpbFSInfo * boot->bpbBytesPerSec || write(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) { - perror("Unable to write bpbFSInfo"); + perr("Unable to write bpbFSInfo"); return FSFATAL; } ret = FSBOOTMOD; @@ -151,7 +151,7 @@ readboot(int dosfs, struct bootblock *bo SEEK_SET) != boot->bpbBackup * boot->bpbBytesPerSec || read(dosfs, backup, sizeof backup) != sizeof backup) { - perror("could not read backup bootblock"); + perr("could not read backup bootblock"); return FSFATAL; } backup[65] = block[65]; /* XXX */ @@ -242,7 +242,7 @@ writefsinfo(int dosfs, struct bootblock if (lseek(dosfs, boot->bpbFSInfo * boot->bpbBytesPerSec, SEEK_SET) != boot->bpbFSInfo * boot->bpbBytesPerSec || read(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) { - perror("could not read fsinfo block"); + perr("could not read fsinfo block"); return FSFATAL; } fsinfo[0x1e8] = (u_char)boot->FSFree; @@ -257,7 +257,7 @@ writefsinfo(int dosfs, struct bootblock != boot->bpbFSInfo * boot->bpbBytesPerSec || write(dosfs, fsinfo, sizeof fsinfo) != sizeof fsinfo) { - perror("Unable to write bpbFSInfo"); + perr("Unable to write bpbFSInfo"); return FSFATAL; } /* Modified: head/sbin/fsck_msdosfs/check.c ============================================================================== --- head/sbin/fsck_msdosfs/check.c Sun Oct 21 11:52:16 2012 (r241805) +++ head/sbin/fsck_msdosfs/check.c Sun Oct 21 12:01:11 2012 (r241806) @@ -26,7 +26,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: check.c,v 1.10 2000/04/25 23:02:51 jdolecek Exp $"); +__RCSID("$NetBSD: check.c,v 1.14 2006/06/05 16:51:18 christos Exp $"); static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ @@ -67,7 +67,7 @@ checkfilesys(const char *fname) printf("\n"); if (dosfs < 0) { - perror("Can't open"); + perr("Can't open `%s'", fname); return 8; } Modified: head/sbin/fsck_msdosfs/dir.c ============================================================================== --- head/sbin/fsck_msdosfs/dir.c Sun Oct 21 11:52:16 2012 (r241805) +++ head/sbin/fsck_msdosfs/dir.c Sun Oct 21 12:01:11 2012 (r241806) @@ -28,7 +28,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: dir.c,v 1.14 1998/08/25 19:18:15 ross Exp $"); +__RCSID("$NetBSD: dir.c,v 1.20 2006/06/05 16:51:18 christos Exp $"); static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ @@ -218,25 +218,26 @@ resetDosDirSection(struct bootblock *boo int b1, b2; cl_t cl; int ret = FSOK; + size_t len; b1 = boot->bpbRootDirEnts * 32; b2 = boot->bpbSecPerClust * boot->bpbBytesPerSec; - if ((buffer = malloc( b1 > b2 ? b1 : b2)) == NULL) { - perror("No space for directory buffer"); + if ((buffer = malloc(len = b1 > b2 ? b1 : b2)) == NULL) { + perr("No space for directory buffer (%zu)", len); return FSFATAL; } - if ((delbuf = malloc(b2)) == NULL) { + if ((delbuf = malloc(len = b2)) == NULL) { free(buffer); - perror("No space for directory delbuf"); + perr("No space for directory delbuf (%zu)", len); return FSFATAL; } if ((rootDir = newDosDirEntry()) == NULL) { free(buffer); free(delbuf); - perror("No space for directory entry"); + perr("No space for directory entry"); return FSFATAL; } @@ -328,7 +329,7 @@ delete(int f, struct bootblock *boot, st off *= boot->bpbBytesPerSec; if (lseek(f, off, SEEK_SET) != off || read(f, delbuf, clsz) != clsz) { - perror("Unable to read directory"); + perr("Unable to read directory"); return FSFATAL; } while (s < e) { @@ -337,7 +338,7 @@ delete(int f, struct bootblock *boot, st } if (lseek(f, off, SEEK_SET) != off || write(f, delbuf, clsz) != clsz) { - perror("Unable to write directory"); + perr("Unable to write directory"); return FSFATAL; } if (startcl == endcl) @@ -475,7 +476,7 @@ readDosDirSection(int f, struct bootbloc off *= boot->bpbBytesPerSec; if (lseek(f, off, SEEK_SET) != off || read(f, buffer, last) != last) { - perror("Unable to read directory"); + perr("Unable to read directory"); return FSFATAL; } last /= 32; @@ -821,7 +822,7 @@ readDosDirSection(int f, struct bootbloc /* create directory tree node */ if (!(d = newDosDirEntry())) { - perror("No space for directory"); + perr("No space for directory"); return FSFATAL; } memcpy(d, &dirent, sizeof(struct dosDirEntry)); @@ -830,7 +831,7 @@ readDosDirSection(int f, struct bootbloc /* Enter this directory into the todo list */ if (!(n = newDirTodo())) { - perror("No space for todo list"); + perr("No space for todo list"); return FSFATAL; } n->next = pendingDirectories; @@ -851,7 +852,7 @@ readDosDirSection(int f, struct bootbloc last *= 32; if (lseek(f, off, SEEK_SET) != off || write(f, buffer, last) != last) { - perror("Unable to write directory"); + perr("Unable to write directory"); return FSFATAL; } mod &= ~THISMOD; @@ -870,7 +871,7 @@ readDosDirSection(int f, struct bootbloc last *= 32; if (lseek(f, off, SEEK_SET) != off || write(f, buffer, last) != last) { - perror("Unable to write directory"); + perr("Unable to write directory"); return FSFATAL; } mod &= ~THISMOD; @@ -941,7 +942,7 @@ reconnect(int dosfs, struct bootblock *b if (!lfbuf) { lfbuf = malloc(boot->ClusterSize); if (!lfbuf) { - perror("No space for buffer"); + perr("No space for buffer"); return FSFATAL; } p = NULL; @@ -965,7 +966,7 @@ reconnect(int dosfs, struct bootblock *b + boot->ClusterOffset * boot->bpbBytesPerSec; if (lseek(dosfs, lfoff, SEEK_SET) != lfoff || (size_t)read(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) { - perror("could not read LOST.DIR"); + perr("could not read LOST.DIR"); return FSFATAL; } p = lfbuf; @@ -995,7 +996,7 @@ reconnect(int dosfs, struct bootblock *b fat[head].flags |= FAT_USED; if (lseek(dosfs, lfoff, SEEK_SET) != lfoff || (size_t)write(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) { - perror("could not write LOST.DIR"); + perr("could not write LOST.DIR"); return FSFATAL; } return FSDIRMOD; Modified: head/sbin/fsck_msdosfs/fat.c ============================================================================== --- head/sbin/fsck_msdosfs/fat.c Sun Oct 21 11:52:16 2012 (r241805) +++ head/sbin/fsck_msdosfs/fat.c Sun Oct 21 12:01:11 2012 (r241806) @@ -26,7 +26,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: fat.c,v 1.12 2000/10/10 20:24:52 is Exp $"); +__RCSID("$NetBSD: fat.c,v 1.18 2006/06/05 16:51:18 christos Exp $"); static const char rcsid[] = "$FreeBSD$"; #endif /* not lint */ @@ -69,6 +69,7 @@ checkdirty(int fs, struct bootblock *boo off_t off; u_char *buffer; int ret = 0; + size_t len; if (boot->ClustMask != CLUST16_MASK && boot->ClustMask != CLUST32_MASK) return 0; @@ -76,20 +77,20 @@ checkdirty(int fs, struct bootblock *boo off = boot->bpbResSectors; off *= boot->bpbBytesPerSec; - buffer = malloc(boot->bpbBytesPerSec); + buffer = malloc(len = boot->bpbBytesPerSec); if (buffer == NULL) { - perror("No space for FAT"); + perr("No space for FAT sectors (%zu)", len); return 1; } if (lseek(fs, off, SEEK_SET) != off) { - perror("Unable to read FAT"); + perr("Unable to read FAT"); goto err; } if ((size_t)read(fs, buffer, boot->bpbBytesPerSec) != boot->bpbBytesPerSec) { - perror("Unable to read FAT"); + perr("Unable to read FAT"); goto err; } @@ -163,10 +164,11 @@ static int _readfat(int fs, struct bootblock *boot, u_int no, u_char **buffer) { off_t off; + size_t len; - *buffer = malloc(boot->FATsecs * boot->bpbBytesPerSec); + *buffer = malloc(len = boot->FATsecs * boot->bpbBytesPerSec); if (*buffer == NULL) { - perror("No space for FAT"); + perr("No space for FAT sectors (%zu)", len); return 0; } @@ -174,13 +176,13 @@ _readfat(int fs, struct bootblock *boot, off *= boot->bpbBytesPerSec; if (lseek(fs, off, SEEK_SET) != off) { - perror("Unable to read FAT"); + perr("Unable to read FAT"); goto err; } if ((size_t)read(fs, *buffer, boot->FATsecs * boot->bpbBytesPerSec) != boot->FATsecs * boot->bpbBytesPerSec) { - perror("Unable to read FAT"); + perr("Unable to read FAT"); goto err; } @@ -207,10 +209,10 @@ readfat(int fs, struct bootblock *boot, if (!_readfat(fs, boot, no, &buffer)) return FSFATAL; - + fat = malloc(len = boot->NumClusters * sizeof(struct fatEntry)); if (fat == NULL) { - perror("No space for FAT"); + perr("No space for FAT clusters (%zu)", len); free(buffer); return FSFATAL; } @@ -428,13 +430,13 @@ clearchain(struct bootblock *boot, struc } int -tryclear(struct bootblock *boot, struct fatEntry *fat, cl_t head, cl_t *trunc) +tryclear(struct bootblock *boot, struct fatEntry *fat, cl_t head, cl_t *truncp) { if (ask(0, "Clear chain starting at %u", head)) { clearchain(boot, fat, head); return FSFATMOD; } else if (ask(0, "Truncate")) { - *trunc = CLUST_EOF; + *truncp = CLUST_EOF; return FSFATMOD; } else return FSERROR; @@ -549,7 +551,7 @@ writefat(int fs, struct bootblock *boot, buffer = malloc(fatsz = boot->FATsecs * boot->bpbBytesPerSec); if (buffer == NULL) { - perror("No space for FAT"); + perr("No space for FAT sectors (%zu)", fatsz); return FSFATAL; } memset(buffer, 0, fatsz); @@ -598,7 +600,7 @@ writefat(int fs, struct bootblock *boot, free(old_fat); p += count; } - + for (cl = CLUST_FIRST; cl < boot->NumClusters; cl++) { switch (boot->ClustMask) { case CLUST32_MASK: @@ -634,7 +636,7 @@ writefat(int fs, struct bootblock *boot, off *= boot->bpbBytesPerSec; if (lseek(fs, off, SEEK_SET) != off || (size_t)write(fs, buffer, fatsz) != fatsz) { - perror("Unable to write FAT"); + perr("Unable to write FAT"); ret = FSFATAL; /* Return immediately? XXX */ } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210211201.q9LC1B5S068529>