Add devsize
This commit is contained in:
parent
c655d8b3ae
commit
9d9936b2bf
@ -68,6 +68,7 @@ ALL = \
|
|||||||
dd \
|
dd \
|
||||||
decomp16 \
|
decomp16 \
|
||||||
dev2name \
|
dev2name \
|
||||||
|
devsize \
|
||||||
df \
|
df \
|
||||||
dhrystone \
|
dhrystone \
|
||||||
diff \
|
diff \
|
||||||
@ -321,6 +322,10 @@ dev2name: dev2name.c
|
|||||||
$(CCLD) -o $@ $?
|
$(CCLD) -o $@ $?
|
||||||
@install -S 4kw $@
|
@install -S 4kw $@
|
||||||
|
|
||||||
|
devsize: devsize.c
|
||||||
|
$(CCLD) -o $@ $?
|
||||||
|
@install -S 4kw $@
|
||||||
|
|
||||||
df: df.c
|
df: df.c
|
||||||
$(CCLD) -I$(SYS) -o $@ $?
|
$(CCLD) -I$(SYS) -o $@ $?
|
||||||
@install -S 4kw $@
|
@install -S 4kw $@
|
||||||
@ -897,6 +902,7 @@ install: \
|
|||||||
/usr/bin/dd \
|
/usr/bin/dd \
|
||||||
/usr/bin/decomp16 \
|
/usr/bin/decomp16 \
|
||||||
/bin/dev2name \
|
/bin/dev2name \
|
||||||
|
/usr/bin/devsize \
|
||||||
/usr/bin/df \
|
/usr/bin/df \
|
||||||
/usr/bin/dhrystone \
|
/usr/bin/dhrystone \
|
||||||
/usr/bin/diff \
|
/usr/bin/diff \
|
||||||
@ -1161,6 +1167,9 @@ install: \
|
|||||||
/bin/dev2name: dev2name
|
/bin/dev2name: dev2name
|
||||||
install -cs -o bin $? $@
|
install -cs -o bin $? $@
|
||||||
|
|
||||||
|
/usr/bin/devsize: devsize
|
||||||
|
install -cs -o bin $? $@
|
||||||
|
|
||||||
/usr/bin/decomp16: decomp16
|
/usr/bin/decomp16: decomp16
|
||||||
install -cs -o bin $? $@
|
install -cs -o bin $? $@
|
||||||
|
|
||||||
|
57
commands/simple/devsize.c
Executable file
57
commands/simple/devsize.c
Executable file
@ -0,0 +1,57 @@
|
|||||||
|
/* Ben Gras
|
||||||
|
*
|
||||||
|
* Based on sizeup() in mkfs.c.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/dir.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <ibm/partition.h>
|
||||||
|
#include <minix/partition.h>
|
||||||
|
#include <minix/u64.h>
|
||||||
|
#include <sys/ioc_disk.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
unsigned long sizeup(char *);
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int sec;
|
||||||
|
|
||||||
|
if(argc != 2) {
|
||||||
|
fprintf(stderr, "Usage: %s <device>\n", argv[0]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%lu\n", sizeup(argv[optind]));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned long sizeup(device)
|
||||||
|
char *device;
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
struct partition entry;
|
||||||
|
unsigned long d;
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
if ((fd = open(device, O_RDONLY)) == -1) {
|
||||||
|
perror("sizeup open");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (ioctl(fd, DIOCGETP, &entry) == -1) {
|
||||||
|
perror("sizeup ioctl");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
close(fd);
|
||||||
|
d = div64u(entry.size, 512);
|
||||||
|
return d;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user