diff options
author | dianshi <dianshi@main.lv> | 2020-06-27 14:40:40 +0100 |
---|---|---|
committer | dianshi <dianshi@main.lv> | 2020-06-27 14:40:40 +0100 |
commit | bf9475850d1cfb233948cd4455f94a1164b75818 (patch) | |
tree | de1dc6303e16bdb86e58e05e6b69570e4ded6ee2 | |
parent | a9d8b8915e5d9f9d2bb30ac94a882795d2a2d517 (diff) | |
download | nmount-bf9475850d1cfb233948cd4455f94a1164b75818.tar.gz nmount-bf9475850d1cfb233948cd4455f94a1164b75818.zip |
sysfs and procfs mounts, added examples how to use
-rw-r--r-- | README.txt | 10 | ||||
-rw-r--r-- | nmount.c | 19 |
2 files changed, 23 insertions, 6 deletions
@@ -1,4 +1,12 @@ nmount -t proc -d /proc2 -f nosuid,nodev,noexec nmount -v -t proc -d /Process -f nosuid,nodev,noexec -nmount -v -t ext4 -s /dev/mmcblk0p7 -d /mnt/disk0 -f nodev,noexec,nosuid
\ No newline at end of file +nmount -v -t ext4 -s /dev/mmcblk0p7 -d /mnt/disk0 -f nodev,noexec,nosuid + +#mount proc +nmount_static -v -t proc -d /Process -f nosuid +#mount dev +nmount_static -v -t devtmpfs -d /Devices -f nosuid,nodev,nosuid +#mount sys +nmount_static -v -t sysfs -d /System -f nosuid,nodec,nosuid +#mount other disk
\ No newline at end of file @@ -86,11 +86,11 @@ static const struct vfs { int nosource; //does fs have source or not vfs_options *options; //hellpers to show all possible options to config fs mount } vfstab[] = { - {"devtmpfs", 0, "/Device", 0, NULL}, + {"devtmpfs", 0, "/Device", 1, NULL}, {"mqueue", 0, "/MQueue/", 0, NULL}, {"proc", 0, "/Process", 1, (struct vfs_options*)&vfs_options_proc}, {"tmpfs", 0, "/Ram", 0, NULL}, - {"sysfs", 0, "/System", 0, NULL}, + {"sysfs", 0, "/System", 1, NULL}, {"ext4", 0, NULL, 0, NULL}, {"vfat", 0, NULL, 0, NULL}, {NULL, 0, NULL, 0, NULL}, @@ -126,6 +126,8 @@ typedef struct { int f_helper; } mount_params; +#define VERBOSE() if (g_params.f_verbose == 1) + static mount_params g_params; void helper(char *progname) @@ -319,19 +321,24 @@ int main(int argc, char **argv) { //find index of fs in fs table fs_idx = get_fs_idx(g_params.f_type); //should allways be possitive as its allready checked + VERBOSE() printf("Filesystem is have index %d\n",fs_idx); + } + } else { + printf("Filesystem type is not set\n"); + return -1; } if (NULL != g_params.f_flags) { char *token = strtok(g_params.f_flags,","); - printf("Flags: %d\n",g_params.mount_flags); + VERBOSE() printf("Flags: %d\n",g_params.mount_flags); while ( token != NULL ) { - printf("Flags: %s\n",token); + VERBOSE() printf("Flags: %s\n",token); g_params.mount_flags |= str2flag(token); - printf("Flags: %d\n",g_params.mount_flags); + VERBOSE() printf("Flags: %d\n",g_params.mount_flags); token = strtok(NULL,","); } } @@ -339,10 +346,12 @@ int main(int argc, char **argv) //if target dir is defined use it if (NULL != g_params.f_target_dir) { + VERBOSE() printf("Target dir %s\n",g_params.f_target_dir); mkdir(g_params.f_target_dir, 0000); //if target dir is not define use default one } else { g_params.f_target_dir = vfstab[fs_idx].mountpoint; + VERBOSE() printf("Default target dir is set to %s\n",g_params.f_target_dir); mkdir(g_params.f_target_dir, 0000); } |