mount: cat /proc/mounts if no arguments given
Signed-off-by: Hiltjo Posthuma <hiltjo@codemadness.org>
This commit is contained in:
parent
e71d009bd1
commit
5f4d18d4fa
29
mount.c
29
mount.c
@ -101,6 +101,23 @@ usage(void)
|
|||||||
argv0);
|
argv0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
catfile(FILE *in, FILE *out)
|
||||||
|
{
|
||||||
|
char buf[BUFSIZ];
|
||||||
|
size_t bytesread;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
if(feof(in))
|
||||||
|
break;
|
||||||
|
bytesread = fread(buf, 1, sizeof(buf), in);
|
||||||
|
if(ferror(in))
|
||||||
|
return 0;
|
||||||
|
fwrite(buf, 1, bytesread, out);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@ -140,8 +157,16 @@ main(int argc, char *argv[])
|
|||||||
usage();
|
usage();
|
||||||
} ARGEND;
|
} ARGEND;
|
||||||
|
|
||||||
if(argc < 1 && aflag == 0)
|
if(argc < 1 && aflag == 0) {
|
||||||
usage();
|
if(!(fp = fopen(files[0], "r")))
|
||||||
|
eprintf("fopen %s:", files[0]);
|
||||||
|
if(catfile(fp, stdout) != 1) {
|
||||||
|
weprintf("error while reading %s:", files[0]);
|
||||||
|
status = EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
if(aflag == 1)
|
if(aflag == 1)
|
||||||
goto mountall;
|
goto mountall;
|
||||||
|
Loading…
Reference in New Issue
Block a user