projects
/
unix-history
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
keep npartitions independent of byte order
[unix-history]
/
usr
/
src
/
sbin
/
mknod
/
mknod.c
#ifndef lint
static char
*
sccsid
=
"@(#)mknod.c 4.2 (Berkeley) %G%"
;
#endif not lint
#include <stdio.h>
main
(
argc
,
argv
)
int
argc
;
char
**
argv
;
{
int
m
,
a
,
b
;
if
(
argc
!=
5
) {
printf
(
"arg count
\n
"
);
goto
usage
;
}
if
(*
argv
[
2
] ==
'b'
)
m
=
060666
;
else
if
(*
argv
[
2
] ==
'c'
)
m
=
020666
;
else
goto
usage
;
a
=
number
(
argv
[
3
]);
if
(
a
<
0
)
goto
usage
;
b
=
number
(
argv
[
4
]);
if
(
b
<
0
)
goto
usage
;
if
(
mknod
(
argv
[
1
],
m
, (
a
<<
8
)|
b
) <
0
) {
fprintf
(
stderr
,
"mknod: "
);
perror
(
argv
[
1
]);
}
exit
(
0
);
usage
:
printf
(
"usage: mknod name b/c major minor
\n
"
);
}
number
(
s
)
char
*
s
;
{
int
n
,
c
;
n
=
0
;
while
(
c
= *
s
++) {
if
(
c
<
'0'
||
c
>
'9'
)
return
(-
1
);
n
=
n
*
10
+
c
-
'0'
;
}
return
(
n
);
}