summaryrefslogtreecommitdiffstats
path: root/sbin/quotacheck
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1997-03-11 12:20:21 +0000
committerpeter <peter@FreeBSD.org>1997-03-11 12:20:21 +0000
commitac28da2dc002612b2fd129500af8084d63aa8504 (patch)
tree8cadfc9709953ec63a6c3fe257fe499055b9f832 /sbin/quotacheck
parent683ee3c015f8c8071f4de0e2cd952c8643315c98 (diff)
downloadFreeBSD-src-ac28da2dc002612b2fd129500af8084d63aa8504.zip
FreeBSD-src-ac28da2dc002612b2fd129500af8084d63aa8504.tar.gz
Merge from Lite2. Note that Lite2 has it's own filesystem clean check
skipping code that overrides ours sooner. One should be eliminated, but for now it works.
Diffstat (limited to 'sbin/quotacheck')
-rw-r--r--sbin/quotacheck/preen.c99
1 files changed, 51 insertions, 48 deletions
diff --git a/sbin/quotacheck/preen.c b/sbin/quotacheck/preen.c
index b560861..09b47c3 100644
--- a/sbin/quotacheck/preen.c
+++ b/sbin/quotacheck/preen.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static const char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
+static const char sccsid[] = "@(#)preen.c 8.5 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/param.h>
@@ -45,7 +45,7 @@ static const char sccsid[] = "@(#)preen.c 8.1 (Berkeley) 6/5/93";
#include <unistd.h>
#include <stdlib.h>
#include <ctype.h>
-#include <fstab.h>
+
#include "fsck.h"
struct part {
@@ -62,19 +62,22 @@ struct disk {
int pid; /* If != 0, pid of proc working on */
} *disks;
-static void addpart __P((char *name, char *fsname, long auxdata));
-static int startdisk __P((struct disk *dk, int (*checkit)()));
-static struct disk *finddisk __P((char *name));
-static char *unrawname __P((char *name));
-static char *rawname __P((char *name));
-
int nrun, ndisks;
char hotroot;
+static void addpart __P((char *name, char *fsname, long auxdata));
+static struct disk *finddisk __P((char *name));
+static char *rawname __P((char *name));
+static int startdisk __P((struct disk *dk,
+ int (*checkit)(char *, char *, long, int)));
+static char *unrawname __P((char *name));
+
int
checkfstab(preen, maxrun, docheck, chkit)
- int preen, maxrun;
- int (*docheck)(), (*chkit)();
+ int preen;
+ int maxrun;
+ int (*docheck)(struct fstab *);
+ int (*chkit)(char *, char *, long, int);
{
register struct fstab *fsp;
register struct disk *dk, *nextdisk;
@@ -93,12 +96,11 @@ checkfstab(preen, maxrun, docheck, chkit)
while ((fsp = getfsent()) != 0) {
if ((auxdata = (*docheck)(fsp)) == 0)
continue;
- if (!preen || (passno == 1 && fsp->fs_passno == 1)) {
- name = blockcheck(fsp->fs_spec);
- if (name) {
- sumstatus = (*chkit)(name,
- fsp->fs_file, auxdata, 0);
- if (sumstatus)
+ if (preen == 0 ||
+ (passno == 1 && fsp->fs_passno == 1)) {
+ if ((name = blockcheck(fsp->fs_spec)) != 0) {
+ if ((sumstatus = (*chkit)(name,
+ fsp->fs_file, auxdata, 0)) != 0)
return (sumstatus);
} else if (preen)
return (8);
@@ -198,7 +200,7 @@ checkfstab(preen, maxrun, docheck, chkit)
return (0);
}
-struct disk *
+static struct disk *
finddisk(name)
char *name;
{
@@ -206,13 +208,11 @@ finddisk(name)
register char *p;
size_t len = 0;
- for (p = name + strlen(name) - 1; p >= name; --p)
+ for (len = strlen(name), p = name + len - 1; p >= name; --p)
if (isdigit(*p)) {
len = p - name + 1;
break;
}
- if (p < name)
- len = strlen(name);
for (dk = disks, dkp = &disks; dk; dkp = &dk->next, dk = dk->next) {
if (strncmp(dk->name, name, len) == 0 &&
@@ -237,7 +237,7 @@ finddisk(name)
return (dk);
}
-void
+static void
addpart(name, fsname, auxdata)
char *name, *fsname;
long auxdata;
@@ -269,10 +269,10 @@ addpart(name, fsname, auxdata)
pt->auxdata = auxdata;
}
-int
+static int
startdisk(dk, checkit)
register struct disk *dk;
- int (*checkit)();
+ int (*checkit)(char *, char *, long, int);
{
register struct part *pt = dk->part;
@@ -288,11 +288,11 @@ startdisk(dk, checkit)
}
char *
-blockcheck(name)
- char *name;
+blockcheck(origname)
+ char *origname;
{
struct stat stslash, stblock, stchar;
- char *raw;
+ char *newname, *raw;
struct fstab *fsinfo;
int retried = 0, l;
@@ -300,60 +300,63 @@ blockcheck(name)
if (stat("/", &stslash) < 0) {
perror("/");
printf("Can't stat root\n");
- return (0);
+ return (origname);
}
+ newname = origname;
retry:
- if (stat(name, &stblock) < 0) {
- perror(name);
- printf("Can't stat %s\n", name);
- return (0);
+ if (stat(newname, &stblock) < 0) {
+ perror(newname);
+ printf("Can't stat %s\n", newname);
+ return (origname);
}
if ((stblock.st_mode & S_IFMT) == S_IFBLK) {
if (stslash.st_dev == stblock.st_rdev)
hotroot++;
- raw = rawname(name);
+ raw = rawname(newname);
if (stat(raw, &stchar) < 0) {
perror(raw);
printf("Can't stat %s\n", raw);
- return (name);
+ return (origname);
}
if ((stchar.st_mode & S_IFMT) == S_IFCHR) {
return (raw);
} else {
printf("%s is not a character device\n", raw);
- return (name);
+ return (origname);
}
} else if ((stblock.st_mode & S_IFMT) == S_IFCHR && !retried) {
- name = unrawname(name);
+ newname = unrawname(origname);
retried++;
goto retry;
} else if ((stblock.st_mode & S_IFMT) == S_IFDIR && !retried) {
- l = strlen(name) - 1;
- if (l > 0 && name[l] == '/')
+ l = strlen(origname) - 1;
+ if (l > 0 && origname[l] == '/')
/* remove trailing slash */
- name[l] = '\0';
- if(!(fsinfo=getfsfile(name))) {
+ origname[l] = '\0';
+ if(!(fsinfo=getfsfile(origname))) {
printf("Can't resolve %s to character special device",
- name);
+ origname);
return (0);
}
- name = fsinfo->fs_spec;
+ newname = fsinfo->fs_spec;
retried++;
goto retry;
}
- printf("Warning: Can't find blockdevice corresponding to name %s\n",
- name);
- return (name);
+ /*
+ * Not a block or character device, just return name and
+ * let the user decide whether to use it.
+ */
+ return (origname);
}
-char *
+static char *
unrawname(name)
char *name;
{
char *dp;
struct stat stb;
- if ((dp = rindex(name, '/')) == 0)
+ if ((dp = strrchr(name, '/')) == 0)
return (name);
if (stat(name, &stb) < 0)
return (name);
@@ -365,14 +368,14 @@ unrawname(name)
return (name);
}
-char *
+static char *
rawname(name)
char *name;
{
static char rawbuf[32];
char *dp;
- if ((dp = rindex(name, '/')) == 0)
+ if ((dp = strrchr(name, '/')) == 0)
return (0);
*dp = 0;
(void)strcpy(rawbuf, name);
OpenPOWER on IntegriCloud