summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoRo <dos21h@gmail.com>2020-06-16 20:56:19 +0100
committerZoRo <dos21h@gmail.com>2020-06-16 20:56:19 +0100
commit21fbf694d06ac7a947c9092e08c3d225983e960a (patch)
tree1787de5158b254e7f7ee83562e01afa0e54ef7dc
downloadnmount-21fbf694d06ac7a947c9092e08c3d225983e960a.tar.gz
nmount-21fbf694d06ac7a947c9092e08c3d225983e960a.zip
Init
-rw-r--r--Makefile2
-rw-r--r--nmount.c117
2 files changed, 119 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..217284f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+make:
+ gcc nmount.c -o nmount \ No newline at end of file
diff --git a/nmount.c b/nmount.c
new file mode 100644
index 0000000..a51664b
--- /dev/null
+++ b/nmount.c
@@ -0,0 +1,117 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/mount.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <getopt.h>
+#include <signal.h>
+
+/////////////////////////////////////////////////////////////////////////////////////////
+/*FLAGS FROM KERNEL*/
+
+//#define MS_RDONLY 1 /* Mount read-only */
+//#define MS_NOSUID 2 /* Ignore suid and sgid bits */
+//#define MS_NODEV 4 /* Disallow access to device special files */
+//#define MS_NOEXEC 8 /* Disallow program execution */
+//#define MS_SYNCHRONOUS 16 /* Writes are synced at once */
+//#define MS_REMOUNT 32 /* Alter flags of a mounted FS */
+//#define MS_MANDLOCK 64 /* Allow mandatory locks on an FS */
+//#define MS_DIRSYNC 128 /* Directory modifications are synchronous */
+//#define MS_NOATIME 1024 /* Do not update access times. */
+//#define MS_NODIRATIME 2048 /* Do not update directory access times */
+//#define MS_BIND 4096
+//#define MS_MOVE 8192
+//#define MS_REC 16384
+//#define MS_VERBOSE 32768 /* War is peace. Verbosity is silence.
+// MS_VERBOSE is deprecated. */
+//#define MS_SILENT 32768
+//#define MS_POSIXACL (1<<16) /* VFS does not apply the umask */
+//#define MS_UNBINDABLE (1<<17) /* change to unbindable */
+//#define MS_PRIVATE (1<<18) /* change to private */
+//#define MS_SLAVE (1<<19) /* change to slave */
+//#define MS_SHARED (1<<20) /* change to shared */
+//#define MS_RELATIME (1<<21) /* Update atime relative to mtime/ctime. */
+//#define MS_KERNMOUNT (1<<22) /* this is a kern_mount call */
+//#define MS_I_VERSION (1<<23) /* Update inode I_version field */
+//#define MS_STRICTATIME (1<<24) /* Always perform atime updates */
+//#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */
+
+
+typedef struct {
+ int f_output; //show statistics of pipe
+ int f_stopzero; //stop if 0 bytes in input
+ int f_nowriteout; // dont write to output
+ int f_graphmode; //show graph
+} mount_params;
+
+static mount_params g_params;
+
+void helper(char *progname)
+{
+ printf("Usage: %s [OPTS]\n\n"
+ "Version: 0.0.1 \n"
+ "\n"
+ , progname);
+}
+
+void sig_handler(int signo)
+{
+ switch(signo)
+ {
+ case SIGINT:
+ //printf("Catch SIGINT Exit\n");
+ //if (g_params.f_output)
+ //{
+ // printf("Data in %d bytes Data out %d bytes",g_stats.cnt_in,g_stats.cnt_out);
+ //}
+ default:
+ printf("Unknown signal %d\n",signo);
+ }
+ exit(0);
+}
+
+int smount(const char *source, const char *target,
+ const char *filesystemtype, unsigned long mountflags,
+ const void *data);
+
+int main(int argc, char **argv)
+{
+ int c;
+
+ printf("One big real mount\n");
+
+ if (signal(SIGINT,sig_handler) == SIG_ERR)
+ {
+ printf("cannot register signal handler\n");
+ exit(1);
+ }
+
+ //process arguments
+ while ((c = getopt(argc, argv, "osng")) != -1)
+ {
+ switch (c)
+ {
+ case 'v':
+ //g_params.f_output = 1;
+ break;
+
+ default:
+ helper(argv[0]);
+ exit(1);
+ }
+ }
+
+ return 0;
+}
+
+int smount(
+ const char *source,
+ const char *target,
+ const char *filesystemtype,
+ unsigned long mountflags,
+ const void *data)
+{
+
+ return 0;
+}