add -a flag umount
This commit is contained in:
parent
daf3409726
commit
6e06cd0912
|
@ -1,9 +1,6 @@
|
|||
#!/bin/sh
|
||||
echo "Umounting..."
|
||||
umount /proc
|
||||
umount /sys
|
||||
umount /dev
|
||||
umount /tmp
|
||||
umount -a
|
||||
|
||||
echo "Closing processes..."
|
||||
kill -a -s TERM
|
||||
|
|
|
@ -3,14 +3,42 @@
|
|||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <mntent.h>
|
||||
#include <sys/mount.h>
|
||||
#include "config.h"
|
||||
|
||||
int parse_fstab(unsigned long flag) {
|
||||
FILE *fp = setmntent(MOUNT_CFG, "r");
|
||||
if (fp == NULL) {
|
||||
fprintf(stderr, "umount: %s\n", strerror(errno));
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct mntent *me;
|
||||
|
||||
int ret = 0;
|
||||
while ((me = getmntent(fp))) {
|
||||
puts(me->mnt_dir);
|
||||
if (umount2(me->mnt_dir, flag) < 0) {
|
||||
fprintf(stderr, "umount: %s: %s\n", me->mnt_dir, strerror(errno));
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
endmntent(fp);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
unsigned long flag = 0;
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "fl")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "afl")) != -1) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
return parse_fstab(flag);
|
||||
|
||||
case 'f':
|
||||
flag |= MNT_FORCE;
|
||||
break;
|
||||
|
@ -20,7 +48,7 @@ int main(int argc, char **argv) {
|
|||
break;
|
||||
|
||||
default:
|
||||
printf("umount [dst1 dst2...]\n\t[-f Force umount] [-l Lazy umount]\n");
|
||||
printf("umount [dst1 dst2...]\n\t[-a Umount all]\n\t[-f Force umount] [-l Lazy umount]\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue