Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x68k/stand/newdisk Fix indent and style.



details:   https://anonhg.NetBSD.org/src/rev/25e7d019f043
branches:  trunk
changeset: 764617:25e7d019f043
user:      isaki <isaki%NetBSD.org@localhost>
date:      Fri Apr 29 05:43:51 2011 +0000

description:
Fix indent and style.

diffstat:

 sys/arch/x68k/stand/newdisk/newdisk.c |  242 +++++++++++++++++----------------
 1 files changed, 123 insertions(+), 119 deletions(-)

diffs (275 lines):

diff -r 2227b1aef792 -r 25e7d019f043 sys/arch/x68k/stand/newdisk/newdisk.c
--- a/sys/arch/x68k/stand/newdisk/newdisk.c     Fri Apr 29 01:53:36 2011 +0000
+++ b/sys/arch/x68k/stand/newdisk/newdisk.c     Fri Apr 29 05:43:51 2011 +0000
@@ -1,3 +1,5 @@
+/*     $NetBSD: newdisk.c,v 1.6 2011/04/29 05:43:51 isaki Exp $        */
+
 /*-
  * Copyright (c) 1999 Minoura Makoto
  * All rights reserved.
@@ -61,144 +63,146 @@
 void
 usage(void)
 {
-    fprintf(stderr,
-           "Usage: %s [-v] [-n] [-f] [-c] [-m /usr/mdec/mboot] "
-           "/dev/rsdXc\n", prog);
-    exit(1);
-    /* NOTREACHED */
+       fprintf(stderr,
+               "Usage: %s [-v] [-n] [-f] [-c] [-m /usr/mdec/mboot] "
+               "/dev/rsdXc\n", prog);
+       exit(1);
+       /* NOTREACHED */
 }
 
 int
 main(int argc, char *argv[])
 {
-    extern int optind;
-    int ch;
-    int fd;
-    struct disklabel label;
+       extern int optind;
+       int ch;
+       int fd;
+       struct disklabel label;
 
-    prog = argv[0];
-    while ((ch = getopt(argc, argv, "vnfcm:p")) != -1) {
-       switch (ch) {
-       case 'v':
-           verbose = 1;
-           break;
-       case 'n':
-           dry_run = 1;
-           break;
-       case 'f':
-           force = 1;
-           break;
-       case 'c':
-           check_only = 1;
-           break;
-       case 'm':
-           mboot = optarg;
-           break;
-       case 'p':
-           mark_only = 1;
-           break;
-       default:
-           usage();
+       prog = argv[0];
+       while ((ch = getopt(argc, argv, "vnfcm:p")) != -1) {
+               switch (ch) {
+               case 'v':
+                       verbose = 1;
+                       break;
+               case 'n':
+                       dry_run = 1;
+                       break;
+               case 'f':
+                       force = 1;
+                       break;
+               case 'c':
+                       check_only = 1;
+                       break;
+               case 'm':
+                       mboot = optarg;
+                       break;
+               case 'p':
+                       mark_only = 1;
+                       break;
+               default:
+                       usage();
+               }
        }
-    }
-    argc -= optind;
-    argv += optind;
+       argc -= optind;
+       argv += optind;
 
-    if (argc != 1)
-       usage();
-
-    fd = opendisk(argv[0], O_RDONLY, dev, MAXPATHLEN, 0);
-    if (fd < 0)
-       err(1, "opening %s", dev);
-    if (access(mboot, R_OK) < 0)
-       err(1, "checking %s", mboot);
+       if (argc != 1)
+               usage();
 
-    if (read(fd, buf, 512) < 0)
-       err(1, "reading %s", dev);
-    if (strncmp(buf, "X68SCSI1", 8) == 0 &&
-       !force)
-       errx(1, "%s is already marked.  Use -f to overwrite the existing mark.");
-    if (check_only)
-       return 0;
+       fd = opendisk(argv[0], O_RDONLY, dev, MAXPATHLEN, 0);
+       if (fd < 0)
+               err(1, "opening %s", dev);
+       if (access(mboot, R_OK) < 0)
+               err(1, "checking %s", mboot);
 
-    if (verbose)
-       fprintf(stderr, "Inspecting %s... ", dev);
+       if (read(fd, buf, 512) < 0)
+               err(1, "reading %s", dev);
+       if (strncmp(buf, "X68SCSI1", 8) == 0 && !force)
+               errx(1, "%s is already marked.  "
+                       "Use -f to overwrite the existing mark.");
+       if (check_only)
+               return 0;
 
-    if (ioctl(fd, DIOCGDINFO, &label) < 0)
-       err(1, "inspecting %s", dev);
-    close(fd);
-    if (label.d_secsize != 512)
-       errx(1, "This type of disk is not supported by NetBSD.");
+       if (verbose)
+               fprintf(stderr, "Inspecting %s... ", dev);
 
-    if (verbose)
-       fprintf(stderr, "total number of sector is %d.\n", label.d_secperunit);
+       if (ioctl(fd, DIOCGDINFO, &label) < 0)
+               err(1, "inspecting %s", dev);
+       close(fd);
+       if (label.d_secsize != 512)
+               errx(1, "This type of disk is not supported by NetBSD.");
 
-    if (verbose)
-       fprintf(stderr, "Building disk mark... ");
-    memset(buf, 0, 3072);
+       if (verbose)
+               fprintf(stderr, "total number of sector is %d.\n",
+                       label.d_secperunit);
+
+       if (verbose)
+               fprintf(stderr, "Building disk mark... ");
+       memset(buf, 0, 3072);
 #define n label.d_secperunit
-    sprintf(buf, "X68SCSI1%c%c%c%c%c%c%c%c%s",
-           2, 0,
-           (n/16777216)%256, (n/65536)%256, (n/256)%256, n%256,
-           1, 0, copyright);
-#undef n
-    if (verbose)
-       fprintf(stderr, "done.\n");
-
-    if (verbose)
-       fprintf(stderr, "Merging %s... ", mboot);
-    fd = open(mboot, O_RDONLY);
-    if (fd < 0)
-       err(1, "opening %s", mboot);
-    if (read(fd, buf+1024, 1024) < 0)
-       err(1, "reading %s", mboot);
-    close(fd);
-    if (verbose)
-       fprintf(stderr, "done.\n");
-
-    if (!mark_only) {
-       if (verbose)
-           fprintf(stderr, "Creating an empty partition table... ");
-#define n (label.d_secperunit/2)
-       sprintf(buf+2048,
-               "X68K%c%c%c%c%c%c%c%c%c%c%c%c",
-               0, 0, 0, 32,
-               (n/16777215)%256, (n/65536)%256, (n/256)%256, n%256,
-               (n/16777215)%256, (n/65536)%256, (n/256)%256, n%256);
+       sprintf(buf, "X68SCSI1%c%c%c%c%c%c%c%c%s",
+               2, 0,
+               (n/16777216)%256, (n/65536)%256, (n/256)%256, n%256,
+               1, 0, copyright);
 #undef n
        if (verbose)
-           fprintf(stderr, "done.\n");
-    }
-
-    if (dry_run) {
-       char filename[MAXPATHLEN] = "/tmp/diskmarkXXXXX";
-       fd = mkstemp(filename);
-       if (fd < 0)
-           err(1, "opening %s", filename);
-       if (write(fd, buf, 4096) < 0)
-           err(1, "writing %s", filename);
-       close(fd);
-       fprintf(stderr, "Disk mark is kept in %s.\n", filename);
-    } else {
-       int mode = 1;
+               fprintf(stderr, "done.\n");
 
        if (verbose)
-           fprintf(stderr, "Writing... ");
-       fd = open(dev, O_WRONLY);
+               fprintf(stderr, "Merging %s... ", mboot);
+       fd = open(mboot, O_RDONLY);
        if (fd < 0)
-           err(1, "opening %s", dev);
-       if (ioctl(fd, DIOCWLABEL, (char *)&mode) < 0)
-           err(1, "DIOCWLABEL %s", dev);
-       if (write(fd, buf, 4096) != 4096) {
-           mode = 0;
-           ioctl(fd, DIOCWLABEL, (char *)&mode);
-           err(1, "DIOCWLABEL %s", dev);
+               err(1, "opening %s", mboot);
+       if (read(fd, buf+1024, 1024) < 0)
+               err(1, "reading %s", mboot);
+       close(fd);
+       if (verbose)
+               fprintf(stderr, "done.\n");
+
+       if (!mark_only) {
+               if (verbose)
+                       fprintf(stderr,
+                               "Creating an empty partition table... ");
+#define n (label.d_secperunit/2)
+               sprintf(buf+2048,
+                       "X68K%c%c%c%c%c%c%c%c%c%c%c%c",
+                       0, 0, 0, 32,
+                       (n/16777215)%256, (n/65536)%256, (n/256)%256, n%256,
+                       (n/16777215)%256, (n/65536)%256, (n/256)%256, n%256);
+#undef n
+               if (verbose)
+                       fprintf(stderr, "done.\n");
        }
-       ioctl(fd, DIOCWLABEL, (char *)&mode);
-       if (verbose)
-           fprintf(stderr, "done.\n");
-       close(fd);
-    }
+
+       if (dry_run) {
+               char filename[MAXPATHLEN] = "/tmp/diskmarkXXXXX";
+               fd = mkstemp(filename);
+               if (fd < 0)
+                       err(1, "opening %s", filename);
+               if (write(fd, buf, 4096) < 0)
+                       err(1, "writing %s", filename);
+               close(fd);
+               fprintf(stderr, "Disk mark is kept in %s.\n", filename);
+       } else {
+               int mode = 1;
 
-    return 0;
+               if (verbose)
+                       fprintf(stderr, "Writing... ");
+               fd = open(dev, O_WRONLY);
+               if (fd < 0)
+                       err(1, "opening %s", dev);
+               if (ioctl(fd, DIOCWLABEL, (char *)&mode) < 0)
+                       err(1, "DIOCWLABEL %s", dev);
+               if (write(fd, buf, 4096) != 4096) {
+                       mode = 0;
+                       ioctl(fd, DIOCWLABEL, (char *)&mode);
+                       err(1, "DIOCWLABEL %s", dev);
+               }
+               ioctl(fd, DIOCWLABEL, (char *)&mode);
+               if (verbose)
+                       fprintf(stderr, "done.\n");
+               close(fd);
+       }
+
+       return 0;
 }



Home | Main Index | Thread Index | Old Index