diff options
author | ZoRo <dos21h@gmail.com> | 2020-06-16 22:36:16 +0100 |
---|---|---|
committer | ZoRo <dos21h@gmail.com> | 2020-06-16 22:36:16 +0100 |
commit | 5f9e33ad5596bb4fc0814e59b9044bce8051c801 (patch) | |
tree | 583288f8bd38e1673d1d539afc588a38e50f948f | |
parent | 21fbf694d06ac7a947c9092e08c3d225983e960a (diff) | |
download | nmount-5f9e33ad5596bb4fc0814e59b9044bce8051c801.tar.gz nmount-5f9e33ad5596bb4fc0814e59b9044bce8051c801.zip |
added 7 fs, intial info structures
-rw-r--r-- | nmount.c | 104 |
1 files changed, 86 insertions, 18 deletions
@@ -37,12 +37,63 @@ //#define MS_STRICTATIME (1<<24) /* Always perform atime updates */ //#define MS_LAZYTIME (1<<25) /* Update the on-disk [acm]times lazily */ +#define STRUCT_LEN(VAR,STRUCT) ((sizeof(VAR)/sizeof(STRUCT))-1) + +typedef struct vfs_option_params { + char *val; + char *descr; +} vfs_option_params; + +vfs_option_params vfs_options_proc_params_hidepid[] = { + {"0","Everybody may access all proc"}, + {"1","User can access only their own proc, not other /proc/[pid]"}, + {"2","As for mode 1, extra hides pid directories of others"}, + {NULL,NULL}, +}; + +vfs_option_params vfs_options_proc_params_gid[] = { + {"gid","usergroup who sees /proc in mode 0"}, + {NULL,NULL}, +}; + +typedef struct vfs_options +{ + char *options; + char *description; + vfs_option_params **params; +} vfs_options; + +vfs_options vfs_options_proc[] = +{ + {"hidepid=\%u" ,"", &vfs_options_proc_params_hidepid}, + {"gid=\%u" ,"user group that can access process", &vfs_options_proc_params_gid}, + {NULL,NULL,NULL} +}; + +static const struct vfs { + char *name; + long flags; + char *mountpoint; + vfs_options *options; +} vfstab[] = { + {"devtmpfs", 0, "/Device", NULL}, + {"mqueue", 0, "/MQueue/", NULL}, + {"proc", 0, "/Process", &vfs_options_proc}, + {"tmpfs", 0, "/Ram", NULL}, + {"sysfs", 0, "/System", NULL}, + {"ext4", 0, NULL, NULL}, + {"vfat", 0, NULL, NULL}, + {NULL, 0, NULL, NULL}, +}; 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 + char *f_device; + char *f_type; + char *f_dir; + char *f_flags;//g_params.f_output = 1; + char *f_options; + int f_verbose; + int f_helper; } mount_params; static mount_params g_params; @@ -51,6 +102,14 @@ void helper(char *progname) { printf("Usage: %s [OPTS]\n\n" "Version: 0.0.1 \n" + "-d device to mount\n" + "-t filesystem type\n" + "-d mount directory\n" + "-f mount flags\n" + "-o mount fs options\n" + "-v verbose output\n" + "-h help options\n" + "-a helper for filetype options\n" "\n" , progname); } @@ -71,13 +130,21 @@ void sig_handler(int signo) exit(0); } -int smount(const char *source, const char *target, - const char *filesystemtype, unsigned long mountflags, - const void *data); +int smount( + const char *source, + const char *target, + const char *filesystemtype, + unsigned long mountflags, + const void *data) +{ + + return 0; +} int main(int argc, char **argv) { int c; + int i; printf("One big real mount\n"); @@ -88,12 +155,13 @@ int main(int argc, char **argv) } //process arguments - while ((c = getopt(argc, argv, "osng")) != -1) + while ((c = getopt(argc, argv, "a")) != -1) { switch (c) { - case 'v': + case 'a': //g_params.f_output = 1; + g_params.f_helper = 1; break; default: @@ -102,16 +170,16 @@ int main(int argc, char **argv) } } - return 0; -} + if (1 == g_params.f_helper) + { + for (i=0;i<STRUCT_LEN(vfstab,struct vfs);i++) + { + printf("%s %s\n",vfstab[i].name,vfstab[i].mountpoint); + } + } -int smount( - const char *source, - const char *target, - const char *filesystemtype, - unsigned long mountflags, - const void *data) -{ return 0; } + + |