umount add

This commit is contained in:
Your Name 2023-12-21 21:59:54 +03:00
parent ea17f21ebf
commit f9050b632e
9 changed files with 47 additions and 20 deletions

1
TODO
View File

@ -22,7 +22,6 @@ tar
Other:
*mount
ps
umount
sysctl
ping
ncat

View File

@ -12,7 +12,7 @@ if [ -z $CC ]; then
fi
if [ -z $projects ]; then
projects="console-tools coreutils sysutils sysutils-linux findutils networking miscutils shell loginutils procps"
projects="console-tools coreutils sysutils-linux findutils networking miscutils shell loginutils procps"
fi
#Compile
@ -25,6 +25,7 @@ for project in $projects; do
for i in $p; do
cd $PROJECT_DIR/$i
echo " * Compile" $i
chmod -v +x build.sh
env CC=$CC CFLAGS="$CFLAGS -I$PROJECT_DIR -I$PROJECT_DIR/include/libmu -lm" OUTPUT="-o $PROJECT_DIR"/bin/$(basename $i) ./build.sh
cd $PROJECT_DIR
done

View File

@ -9,13 +9,6 @@ typedef struct {
unsigned int val;
} MU_MOUNT_OPTS;
#if defined(__BSD__)
#define MS_RDONLY MNT_RDONLY
#define MS_REMOUNT 0
#define MS_SYNCHRONOUS MNT_SYNCHRONOUS
#define MS_NODEV MNT_NODEV
#endif
MU_MOUNT_OPTS mu_options[] = {
{"defaults", NULL, NULL, 0},
{"ro", "rw", "Read only / Read and write", MS_RDONLY},

View File

@ -19,7 +19,7 @@ int compare(FILE *fp1, FILE *fp2) {
if (ch1 != ch2) {
if (!s_flag)
printf("files differ at byte %lu\n", byte);
printf("files differ at byte %zu\n", byte);
return 1;
}

View File

@ -8,7 +8,7 @@
#define OS_NAME "Android"
#elif defined(__linux__)
#define OS_NAME "linux"
#define OS_NAME "Linux"
#elif defined(__OpenBSD__)
#define OS_NAME "OpenBSD"

View File

@ -8,15 +8,7 @@
#include "config.h"
int do_mount(const char *src, const char *dst, const char *fs_type, unsigned long opt) {
#if defined(__linux__)
int ret = mount(src, dst, fs_type, opt, NULL);
#else
int ret = -1;
#endif
if (ret < 0) {
if (mount(src, dst, fs_type, opt, NULL) < 0) {
fprintf(stderr, "mount: %s: %s\n", src, strerror(errno));
return 1;
}

View File

@ -0,0 +1,2 @@
#!/bin/sh
echo ./*.c $CFLAGS $OUTPUT | xargs $CC

View File

@ -0,0 +1,40 @@
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/mount.h>
int main(int argc, char **argv) {
unsigned long flag = 0;
int opt;
while ((opt = getopt(argc, argv, "fl")) != -1) {
switch (opt) {
case 'f':
flag |= MNT_FORCE;
break;
case 'l':
flag |= MNT_DETACH;
break;
default:
printf("umount [dst1 dst2...]\n\t[-f Force umount] [-l Lazy umount]\n");
return 0;
}
}
argv += optind;
argc -= optind;
int ret = 0;
for (int i = 0; i < argc; i++) {
if (umount2(argv[i], flag) < 0) {
fprintf(stderr, "umount: %s: %s\n", argv[i], strerror(errno));
ret = 1;
}
}
return ret;
}