aboutsummaryrefslogtreecommitdiff
path: root/toys/lsb/mknod.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2012-11-13 17:14:08 -0600
committerRob Landley <rob@landley.net>2012-11-13 17:14:08 -0600
commit7aa651a6a4496d848f86de9b1e6b3a003256a01f (patch)
tree6995fb4b7cc2e90a6706b0239ebaf95d9dbab530 /toys/lsb/mknod.c
parent571b0706cce45716126776d0ad0f6ac65f4586e3 (diff)
downloadtoybox-7aa651a6a4496d848f86de9b1e6b3a003256a01f.tar.gz
Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
The actual code should be the same afterward, this is just cosmetic refactoring.
Diffstat (limited to 'toys/lsb/mknod.c')
-rw-r--r--toys/lsb/mknod.c47
1 files changed, 22 insertions, 25 deletions
diff --git a/toys/lsb/mknod.c b/toys/lsb/mknod.c
index c1d78b10..bf9288ae 100644
--- a/toys/lsb/mknod.c
+++ b/toys/lsb/mknod.c
@@ -1,6 +1,4 @@
-/* vi: set sw=4 ts=4:
- *
- * mknod.c - make block or character special file
+/* mknod.c - make block or character special file
*
* Copyright 2012 Elie De Brauwer <eliedebrauwer@gmail.com>
*
@@ -9,15 +7,15 @@
USE_MKNOD(NEWTOY(mknod, "<2>4", TOYFLAG_BIN))
config MKNOD
- bool "mknod"
- default y
- help
- usage: mknod NAME TYPE [MAJOR MINOR]
-
- Create a special file NAME with a given type, possible types are
- b block device
- c or u character device
- p named pipe (ignores MAJOR/MINOR)
+ bool "mknod"
+ default y
+ help
+ usage: mknod NAME TYPE [MAJOR MINOR]
+
+ Create a special file NAME with a given type, possible types are
+ b block device
+ c or u character device
+ p named pipe (ignores MAJOR/MINOR)
*/
#define FOR_mknod
@@ -25,20 +23,19 @@ config MKNOD
void mknod_main(void)
{
- mode_t modes[] = {S_IFIFO, S_IFCHR, S_IFCHR, S_IFBLK};
- int major=0, minor=0, type;
- int mode = 0660;
-
- type = stridx("pcub", *toys.optargs[1]);
- if (type == -1) perror_exit("bad type '%c'", *toys.optargs[1]);
- if (type) {
- if (toys.optc != 4) perror_exit("need major/minor");
+ mode_t modes[] = {S_IFIFO, S_IFCHR, S_IFCHR, S_IFBLK};
+ int major=0, minor=0, type;
+ int mode = 0660;
- major = atoi(toys.optargs[2]);
- minor = atoi(toys.optargs[3]);
- }
+ type = stridx("pcub", *toys.optargs[1]);
+ if (type == -1) perror_exit("bad type '%c'", *toys.optargs[1]);
+ if (type) {
+ if (toys.optc != 4) perror_exit("need major/minor");
- if (mknod(toys.optargs[0], mode | modes[type], makedev(major, minor)))
- perror_exit("mknod %s failed", toys.optargs[0]);
+ major = atoi(toys.optargs[2]);
+ minor = atoi(toys.optargs[3]);
+ }
+ if (mknod(toys.optargs[0], mode | modes[type], makedev(major, minor)))
+ perror_exit("mknod %s failed", toys.optargs[0]);
}