terminate swap list with NODEV, not 0: 0 is a valid (if unusual) dev
[unix-history] / usr / src / usr.sbin / config / mkswapconf.c
index 0b29489..21a39ac 100644 (file)
@@ -1,12 +1,13 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)mkswapconf.c       5.1 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)mkswapconf.c       5.11 (Berkeley) %G%";
+#endif /* not lint */
 
 /*
  * Build a swap configuration file.
 
 /*
  * Build a swap configuration file.
@@ -36,7 +37,7 @@ do_swap(fl)
        register struct file_list *fl;
 {
        FILE *fp;
        register struct file_list *fl;
 {
        FILE *fp;
-       char  swapname[80], *cp;
+       char  swapname[80];
        register struct file_list *swap;
        dev_t dev;
 
        register struct file_list *swap;
        dev_t dev;
 
@@ -50,8 +51,8 @@ do_swap(fl)
                perror(path(swapname));
                exit(1);
        }
                perror(path(swapname));
                exit(1);
        }
-       fprintf(fp, "#include \"../h/param.h\"\n");
-       fprintf(fp, "#include \"../h/conf.h\"\n");
+       fprintf(fp, "#include \"sys/param.h\"\n");
+       fprintf(fp, "#include \"sys/conf.h\"\n");
        fprintf(fp, "\n");
        /*
         * If there aren't any swap devices
        fprintf(fp, "\n");
        /*
         * If there aren't any swap devices
@@ -66,8 +67,6 @@ do_swap(fl)
        }
        fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\n",
                major(fl->f_rootdev), minor(fl->f_rootdev));
        }
        fprintf(fp, "dev_t\trootdev = makedev(%d, %d);\n",
                major(fl->f_rootdev), minor(fl->f_rootdev));
-       fprintf(fp, "dev_t\targdev  = makedev(%d, %d);\n",
-               major(fl->f_argdev), minor(fl->f_argdev));
        fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\n",
                major(fl->f_dumpdev), minor(fl->f_dumpdev));
        fprintf(fp, "\n");
        fprintf(fp, "dev_t\tdumpdev = makedev(%d, %d);\n",
                major(fl->f_dumpdev), minor(fl->f_dumpdev));
        fprintf(fp, "\n");
@@ -78,7 +77,7 @@ do_swap(fl)
                    major(dev), minor(dev), swap->f_swapsize, swap->f_fn);
                swap = swap->f_next;
        } while (swap && swap->f_type == SWAPSPEC);
                    major(dev), minor(dev), swap->f_swapsize, swap->f_fn);
                swap = swap->f_next;
        } while (swap && swap->f_type == SWAPSPEC);
-       fprintf(fp, "\t{ 0, 0, 0 }\n");
+       fprintf(fp, "\t{ NODEV, 0, 0 }\n");
        fprintf(fp, "};\n");
        fclose(fp);
        return (swap);
        fprintf(fp, "};\n");
        fclose(fp);
        return (swap);
@@ -136,7 +135,7 @@ nametodev(name, defunit, defpartition)
        }
        if (devtablenotread)
                initdevtable();
        }
        if (devtablenotread)
                initdevtable();
-       for (dp = devtable; dp->dev_next; dp = dp->dev_next)
+       for (dp = devtable; dp; dp = dp->dev_next)
                if (eq(name, dp->dev_name))
                        break;
        if (dp == 0) {
                if (eq(name, dp->dev_name))
                        break;
        if (dp == 0) {
@@ -155,12 +154,12 @@ devtoname(dev)
 
        if (devtablenotread)
                initdevtable();
 
        if (devtablenotread)
                initdevtable();
-       for (dp = devtable; dp->dev_next; dp = dp->dev_next)
+       for (dp = devtable; dp; dp = dp->dev_next)
                if (major(dev) == dp->dev_major)
                        break;
        if (dp == 0)
                dp = devtable;
                if (major(dev) == dp->dev_major)
                        break;
        if (dp == 0)
                dp = devtable;
-       sprintf(buf, "%s%d%c", dp->dev_name,
+       (void) sprintf(buf, "%s%d%c", dp->dev_name,
                minor(dev) >> 3, (minor(dev) & 07) + 'a');
        return (ns(buf));
 }
                minor(dev) >> 3, (minor(dev) & 07) + 'a');
        return (ns(buf));
 }
@@ -172,7 +171,7 @@ initdevtable()
        register struct devdescription **dp = &devtable;
        FILE *fp;
 
        register struct devdescription **dp = &devtable;
        FILE *fp;
 
-       sprintf(buf, "../conf/devices.%s", machinename);
+       (void) sprintf(buf, "../conf/devices.%s", machinename);
        fp = fopen(buf, "r");
        if (fp == NULL) {
                fprintf(stderr, "config: can't open %s\n", buf);
        fp = fopen(buf, "r");
        if (fp == NULL) {
                fprintf(stderr, "config: can't open %s\n", buf);