summaryrefslogtreecommitdiff
path: root/md/notes/xos/nmount.md
blob: 8cfca03921f0fe3e67262a17d4d7262173c00233 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
title:nmount - alternative mount
keywords:linux,qemu,mount.linux,

# nmount - alternative mount

## Intro

So simple mount utility, to mount files and give params to mount syscall.


## Ideas

Busybox needs /etc/fstab to work, minibase where using predefined locations.
If this is all removed then its become portable tool.

Minibase - 
https://github.com/arsv/minibase/blob/master/src/root/kmount.c  

Mount syscall -
https://man7.org/linux/man-pages/man2/mount.2.html  

```c
#include <sys/mount.h>

int mount(
    const char*     source, 
    const char*     target,
    const char*     filesystemtype, 
    unsigned long   mountflags,
    const void*     data);
```

Syscall looks pretty simple

So comamnd looks simple to check with filesystems kernel supports check
procfs /proc/filesystems


Run:
```
cat /proc/filesystems
```
Output:
```
nodev   sysfs
nodev   tmpfs
nodev   bdev
nodev   proc
nodev   cgroup
nodev   cgroup2
nodev   cpuset
nodev   devtmpfs
nodev   binfmt_misc
nodev   configfs
nodev   debugfs
nodev   tracefs
nodev   securityfs
nodev   sockfs
nodev   bpf
nodev   pipefs
nodev   ramfs
nodev   hugetlbfs
nodev   devpts
nodev   autofs
nodev   mqueue
nodev   pstore
        ext3
        ext2
        ext4
nodev   vboxsf
        vfat
        fuseblk
nodev   fuse
nodev   fusectl
```

## Use

Currently help is supproted for procfs,devtmpfs and sysfs. Next to add is ext4

```
nmount_static -v -t proc -d /Process -f nosuid,nodev,noexec,realtime
nmount_static -v -t devtmpfs -d /Devices -f nosuid
nmount_static -v -t sysfs -d /System -f nosuid,nodec,nosuid,realtime
```

available options
```
Usage: ./nmount [OPTS]

Version: 0.0.1 
-s source directory
-d target directory
-t filesystem type
-f mount flags
-o mount fs options
-v verbose output
-h help options
-a helper for filetype options
```

output help thats shows all availiable options, for fs
```
./nmount -f proc -a
devtmpfs /Device
mqueue /MQueue/
proc /Process
    hidepid=%u 
        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
    gid=%u user group that can access process
        gid usergroup who sees /proc in mode 0
tmpfs /Ram
sysfs /System
ext4 (null)
vfat (null)

```

Its create directory if its not excist

## Source

http://git.main.lv/cgit.cgi/nmount.git/

Compile:
```
make
```

create one dynamic and one static binary


## Links
https://man7.org/linux/man-pages/man2/mount.2.html
https://github.com/arsv/minibase/blob/master/src/root/kmount.c