buninu-linux 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,155 @@
1
+ # ip — show and configure network interfaces, addresses and routes
2
+
3
+ `/bin/ip` is a Bun script with the iproute2 command grammar. It reads
4
+ `/sys/class/net` and `/proc/net`, and configures the kernel through the
5
+ classic `SIOC*` ioctls on an AF_INET socket bound in `/lib/dlopen.js` — the
6
+ same calls `init.js` uses to bring up `lo` and `eth0` at boot. It does not
7
+ speak rtnetlink, which keeps it small; the limits that come with that are
8
+ listed at the end.
9
+
10
+ ## Synopsis
11
+
12
+ ```sh
13
+ ip [-4 | -6] [-br] OBJECT [COMMAND] [ARGUMENTS]
14
+ ip -h | --help | help # this page
15
+ OBJECT := link | address | route | neighbour
16
+ ```
17
+
18
+ Any unambiguous prefix works, as in iproute2: `ip a`, `ip addr`, `ip li`,
19
+ `ip r`, `ip n`, and `show`/`list`/`ls`, `del`/`delete`.
20
+
21
+ ## Global options
22
+
23
+ | Option | Meaning |
24
+ |---|---|
25
+ | `-4` / `-6` | Show only IPv4 / IPv6 addresses. |
26
+ | `-br`, `-brief` | One line per interface. |
27
+ | `-f inet\|inet6` | Same as `-4` / `-6`. |
28
+ | `-c`, `-s`, `-d`, `-o`, `-p` | Accepted for muscle memory, no effect. |
29
+
30
+ ## Links
31
+
32
+ ```sh
33
+ ip link # every interface: flags, mtu, state, MAC
34
+ ip -br link # eth0 UP 52:54:00:12:34:56 <BROADCAST,...>
35
+ ip link show eth0
36
+ ip link set eth0 up
37
+ ip link set eth0 down
38
+ ip link set eth0 mtu 1400
39
+ ip link set eth0 address 02:00:00:00:00:01 # interface must be down
40
+ ip link set eth0 name lan0
41
+ ip link set eth0 promisc on
42
+ ip link set eth0 up mtu 9000 # several changes at once
43
+ ```
44
+
45
+ `ip link add`/`delete` (vlan, bridge, dummy, ...) need rtnetlink and are not
46
+ available.
47
+
48
+ ## Addresses
49
+
50
+ ```sh
51
+ ip addr # links plus their inet / inet6 addresses
52
+ ip -br addr # eth0 UP 10.0.2.15/24 fec0::5054:ff:fe12:3456/64
53
+ ip -4 addr show eth0
54
+ ip addr add 10.0.2.15/24 dev eth0
55
+ ip addr add 192.168.1.10/24 brd + dev eth0
56
+ ip addr replace 192.168.1.11/24 dev eth0 # change the address in place
57
+ ip addr del 10.0.2.15/24 dev eth0
58
+ ip addr flush dev eth0
59
+ ```
60
+
61
+ One IPv4 address per interface: `add` refuses when one is already set (use
62
+ `replace`, or `del` first). IPv6 addresses are shown from
63
+ `/proc/net/if_inet6` but cannot be added or removed here.
64
+
65
+ ## Routes
66
+
67
+ ```sh
68
+ ip route # default via 10.0.2.2 dev eth0
69
+ # 10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15
70
+ ip route add default via 10.0.2.2
71
+ ip route add default via 10.0.2.2 dev eth0 metric 100
72
+ ip route add 192.168.5.0/24 via 10.0.2.1
73
+ ip route add 10.10.0.0/16 dev eth0 # on-link, no gateway
74
+ ip route add 10.0.2.99 dev eth0 # host route (/32)
75
+ ip route replace default via 10.0.2.1
76
+ ip route del default
77
+ ip route del 192.168.5.0/24
78
+ ```
79
+
80
+ Without `dev`, the interface whose subnet contains the gateway is picked.
81
+ IPv6 routes and `ip route get` are not available.
82
+
83
+ ## Neighbours
84
+
85
+ ```sh
86
+ ip neigh # 10.0.2.2 dev eth0 lladdr 52:55:0a:00:02:02 REACHABLE
87
+ ```
88
+
89
+ Read from `/proc/net/arp`. Entries cannot be added or flushed here.
90
+
91
+ ## Bringing up a wired network by hand
92
+
93
+ The QEMU user-mode network `init.js` configures at boot, done manually:
94
+
95
+ ```sh
96
+ ip link set eth0 up
97
+ ip addr add 10.0.2.15/24 dev eth0
98
+ ip route add default via 10.0.2.2
99
+ echo 'nameserver 10.0.2.3' > /etc/resolv.conf
100
+ ip -br addr && ip route
101
+ ```
102
+
103
+ A real Ethernet port is the same three commands once its driver is loaded
104
+ and the cable shows `LOWER_UP` in `ip link`; the address and gateway come
105
+ from your network (there is no DHCP client yet). If `ip link` shows no
106
+ `eth0`, load the driver first from the Bun REPL:
107
+
108
+ ```js
109
+ cfg.net // loads network modules and matches PCI/USB network devices
110
+ ```
111
+
112
+ It uses `/lib/modprobe.js`'s `autoload()`, which reads each device's
113
+ `modalias` under `/sys/bus/{pci,virtio,usb}/devices` and loads whatever
114
+ `modules.alias` says claims it. An image built with `--real` carries Intel
115
+ `e1000`/`e1000e`/`igb`/`igc`, Realtek `r8169` (+ PHY), Atheros `alx`,
116
+ Broadcom `tg3` and the USB dongles `r8152`, `ax88179_178a`, `cdc_ether`.
117
+ A single module by name: `require("/lib/modprobe.js").modprobe("e1000e")`.
118
+
119
+ ## Output format
120
+
121
+ `ip link` / `ip addr` print the iproute2 layout:
122
+
123
+ ```
124
+ 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 state UP qlen 1000
125
+ link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
126
+ inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
127
+ inet6 fe80::5054:ff:fe12:3456/64 scope link
128
+ ```
129
+
130
+ `NO-CARRIER` appears when the link is up but has no carrier (unplugged, or
131
+ the driver never attached).
132
+
133
+ ## Limits of the ioctl approach
134
+
135
+ - One IPv4 address per interface, no secondary addresses, no labels.
136
+ - IPv6: display only.
137
+ - No `link add`/`del`, no `route get`, no `neigh add`, no policy routing,
138
+ no netns.
139
+ - Route `proto`, `scope`, `src` and `table` words are accepted and ignored.
140
+
141
+ ## Exit status
142
+
143
+ `0` ok, `1` bad usage or unknown object, `2` the kernel refused
144
+ (`RTNETLINK answers: ...` style messages, plus the errno text).
145
+
146
+ ## See also
147
+
148
+ - `mount --help`, `umount --help`
149
+ - [ip(8)](https://man7.org/linux/man-pages/man8/ip.8.html),
150
+ [netdevice(7)](https://man7.org/linux/man-pages/man7/netdevice.7.html),
151
+ [route(7)](https://man7.org/linux/man-pages/man7/route.7.html)
152
+ - [/proc/net/route](https://docs.kernel.org/filesystems/proc.html#networking-info-in-proc-net),
153
+ [sysfs net class](https://docs.kernel.org/ABI/testing/sysfs-class-net.html)
154
+ - Source: `initramfs/bin/ip`, `initramfs/lib/dlopen.js` in
155
+ [buninu-linux](https://github.com/jjtseng93/buninu-linux)
@@ -0,0 +1,155 @@
1
+ # mount — mount a filesystem
2
+
3
+ `/bin/mount` is a Bun script. It calls `mount(2)` through `/lib/dlopen.js`
4
+ and loads the kernel modules a filesystem or a disk needs through
5
+ `/lib/modprobe.js`, because on Buninu Linux there is no `/sbin/modprobe` for
6
+ the kernel to ask.
7
+
8
+ ## Synopsis
9
+
10
+ ```sh
11
+ mount # list mounted filesystems
12
+ mount [-fv] [-t TYPE] [-o OPTIONS] SOURCE TARGET
13
+ mount -L LABEL | -U UUID [-o OPTIONS] TARGET
14
+ mount --bind | --rbind | --move OLD NEW
15
+ mount -o remount[,ro|rw] TARGET
16
+ mount -h | --help # this page
17
+ ```
18
+
19
+ ## Options
20
+
21
+ | Option | Meaning |
22
+ |---|---|
23
+ | `-t TYPE` | Filesystem type. Omitted or `auto`: read the superblock of SOURCE and pick one. |
24
+ | `-o OPTIONS` | Comma-separated list, see below. May be repeated. |
25
+ | `-r`, `--read-only` | Same as `-o ro`. |
26
+ | `-w`, `--rw` | Same as `-o rw`. |
27
+ | `-L LABEL`, `-U UUID` | Find the block device by label or UUID (ext2/3/4, FAT, exFAT, NTFS serial). |
28
+ | `-B`, `--bind` | Bind-mount a directory or file somewhere else. |
29
+ | `-R`, `--rbind` | Bind, including everything mounted below OLD. |
30
+ | `-M`, `--move` | Move a mount to a new place. |
31
+ | `--make-shared`, `--make-private`, `--make-rshared`, `--make-rprivate` | Change mount propagation of TARGET. |
32
+ | `--mkdir` | Create TARGET first. |
33
+ | `-v` | Say what is being loaded and mounted. |
34
+ | `-f`, `--fake` | Show the `mount(2)` call and stop. |
35
+
36
+ `-f` and `-v` may be combined as `-fv` or `-vf`; this probes and reports the
37
+ filesystem without performing the mount.
38
+
39
+ ### `-o` words
40
+
41
+ Flags: `ro` `rw` `nosuid` `suid` `nodev` `dev` `noexec` `exec` `sync` `async`
42
+ `dirsync` `noatime` `atime` `nodiratime` `relatime` `strictatime` `lazytime`
43
+ `nosymfollow` `remount` `bind` `rbind` `move` `shared` `private` `slave`
44
+ `unbindable` `defaults`.
45
+
46
+ Anything else (`size=64M`, `iocharset=utf8`, `uid=1000`, `force`, ...) goes
47
+ to the filesystem driver unchanged.
48
+
49
+ ## Examples
50
+
51
+ ### tmpfs
52
+
53
+ ```sh
54
+ mount -t tmpfs tmpfs /mnt/scratch
55
+ mount -t tmpfs -o size=64M,mode=1777 tmpfs /tmp/big
56
+ mount -t tmpfs -o remount,size=256M tmpfs /tmp/big # grow it later
57
+ ```
58
+
59
+ ### ext4 (a Linux disk or partition)
60
+
61
+ ```sh
62
+ mount /dev/vda2 /mnt # type detected, ext4 + jbd2 loaded
63
+ mount -t ext4 -o ro,noatime /dev/vda2 /mnt
64
+ mount -L rootfs /mnt # by label
65
+ mount -U 3f2a...-... /mnt # by UUID
66
+ mount -o remount,rw /mnt # flip an ro mount to rw
67
+ ```
68
+
69
+ `ext3` volumes mount with the ext4 driver; `ext2` uses its own module.
70
+
71
+ ### A Windows disk (NTFS)
72
+
73
+ ```sh
74
+ mount /dev/sda3 /mnt/windows # ntfs3, read-write
75
+ mount -t ntfs3 -o ro /dev/sda3 /mnt/windows # look, don't touch
76
+ mount -t ntfs3 -o force /dev/sda3 /mnt/windows # volume left dirty by Windows
77
+ mount -t ntfs3 -o windows_names,uid=1000,gid=1000 /dev/sda3 /mnt/windows
78
+ ```
79
+
80
+ Windows Fast Startup and hibernation leave the volume marked dirty; ntfs3
81
+ then refuses to mount read-write. Either boot Windows and shut it down
82
+ fully, mount `-o ro`, or pass `force`. `windows_names` rejects names Windows
83
+ could not open. The type name `ntfs` is accepted as an alias for `ntfs3`.
84
+
85
+ ### The EFI system partition, USB sticks, SD cards (FAT / exFAT)
86
+
87
+ ```sh
88
+ mount /dev/vda1 /mnt/efi # vfat, detected
89
+ mount -t vfat -o iocharset=utf8,umask=022 /dev/sdb1 /mnt/usb
90
+ mount -t exfat -o uid=1000,gid=1000 /dev/sdb1 /mnt/card
91
+ ```
92
+
93
+ FAT and exFAT need NLS tables (`nls_utf8`, `nls_cp437`, `nls_iso8859-1`);
94
+ `mount` loads them before calling the kernel, and also whatever
95
+ `iocharset=`/`codepage=` names, if the module is shipped.
96
+
97
+ ### Bind mounts and moves
98
+
99
+ ```sh
100
+ mount --bind /tmp/home /buninu/home
101
+ mount --bind -o ro /usr/share/doc /mnt/doc # bind, then remount read-only
102
+ mount --rbind / /mnt/root # with all submounts
103
+ mount --move /mnt/usb /media/usb
104
+ ```
105
+
106
+ ### Pseudo filesystems
107
+
108
+ ```sh
109
+ mkdir -p /dev/pts && mount -t devpts -o gid=5,mode=620,ptmxmode=666 devpts /dev/pts
110
+ mount -t proc proc /proc
111
+ mount -t sysfs sysfs /sys
112
+ mount -t devtmpfs devtmpfs /dev
113
+ mount -t cgroup2 none /sys/fs/cgroup
114
+ mount -t debugfs none /sys/kernel/debug
115
+ ```
116
+
117
+ `/dev/pts` matters: since Linux 4.7 opening `/dev/ptmx` goes through
118
+ `/dev/pts/ptmx`, so without this mount every pty open fails with `ENODEV`.
119
+ `init.js` mounts it at boot.
120
+
121
+ ### Listing
122
+
123
+ ```sh
124
+ mount # SOURCE on TARGET type TYPE (OPTIONS), from /proc/self/mounts
125
+ cat /proc/self/mountinfo # the long form
126
+ ```
127
+
128
+ ## How devices and drivers are found
129
+
130
+ - A missing `/dev/vd*`, `/dev/sd*` or `/dev/nvme*` node makes `mount` load
131
+ `virtio_blk`, `sd_mod` (+ `ahci`, `usb_storage`) or `nvme` and wait up to
132
+ 3 s for devtmpfs to create it.
133
+ - The filesystem driver is loaded when `/proc/filesystems` does not list the
134
+ type; `modules.alias` turns `fs-ntfs` into `ntfs3`, `fs-ext3` into `ext4`.
135
+ - Which modules are in the image is decided by `fetch-alpine.sh` in the
136
+ build tree; `--real` adds `sd_mod`, `ahci`, `nvme` and `usb-storage`.
137
+
138
+ ## Exit status
139
+
140
+ `0` mounted, `1` bad usage, `32` the mount itself failed. Messages follow
141
+ util-linux wording, and `dmesg` usually has the kernel's reason for `EINVAL`.
142
+
143
+ ## See also
144
+
145
+ - `umount --help`, `ip --help`
146
+ - [mount(2)](https://man7.org/linux/man-pages/man2/mount.2.html),
147
+ [mount(8)](https://man7.org/linux/man-pages/man8/mount.8.html)
148
+ - [tmpfs](https://docs.kernel.org/filesystems/tmpfs.html),
149
+ [ext4](https://docs.kernel.org/admin-guide/ext4.html),
150
+ [ntfs3](https://docs.kernel.org/filesystems/ntfs3.html),
151
+ [vfat](https://docs.kernel.org/filesystems/vfat.html),
152
+ [devpts](https://docs.kernel.org/filesystems/devpts.html)
153
+ - Source: `initramfs/bin/mount`, `initramfs/lib/dlopen.js`,
154
+ `initramfs/lib/modprobe.js` in
155
+ [buninu-linux](https://github.com/jjtseng93/buninu-linux)
@@ -0,0 +1,15 @@
1
+ # poweroff — power off Buninu Linux
2
+
3
+ `poweroff` flushes pending filesystem writes with `sync(2)`, then requests
4
+ `LINUX_REBOOT_CMD_POWER_OFF` through Linux `reboot(2)`. It does not invoke a
5
+ service manager or another command.
6
+
7
+ ## Usage
8
+
9
+ ```sh
10
+ poweroff
11
+ poweroff --help
12
+ ```
13
+
14
+ The caller needs the kernel's `CAP_SYS_BOOT` capability. Buninu's root shell
15
+ has it; otherwise the command reports `Operation not permitted` and exits.
@@ -0,0 +1,48 @@
1
+ # umount — unmount a filesystem
2
+
3
+ `/bin/umount` is a Bun script that calls `umount2(2)` through
4
+ `/lib/dlopen.js`.
5
+
6
+ ## Synopsis
7
+
8
+ ```sh
9
+ umount [-f] [-l] [-R] [-v] TARGET...
10
+ umount -h | --help
11
+ ```
12
+
13
+ TARGET is a mount point. Naming the device (`umount /dev/vda1`) is not
14
+ supported; use `mount` with no arguments to see where it is mounted.
15
+
16
+ ## Options
17
+
18
+ | Option | Meaning |
19
+ |---|---|
20
+ | `-l`, `--lazy` | Detach now, clean up when the last user goes away (`MNT_DETACH`). |
21
+ | `-f`, `--force` | Force, for unreachable network filesystems (`MNT_FORCE`). |
22
+ | `-R`, `--recursive` | Also unmount everything mounted below TARGET, deepest first. |
23
+ | `-v` | Report each successful unmount. |
24
+
25
+ ## Examples
26
+
27
+ ```sh
28
+ umount /mnt
29
+ umount -l /mnt/windows # something still has a file open
30
+ umount -R /mnt/root # a tree made with mount --rbind
31
+ umount /tmp/big /mnt/usb # several at once
32
+ ```
33
+
34
+ "target is busy" means a process has its working directory or an open file
35
+ inside the mount. On the Bun REPL, `process.chdir("/")` is usually the fix;
36
+ `-l` is the escape hatch.
37
+
38
+ ## Exit status
39
+
40
+ `0` all targets unmounted, `1` bad usage, `32` at least one failed.
41
+
42
+ ## See also
43
+
44
+ - `mount --help`
45
+ - [umount(2)](https://man7.org/linux/man-pages/man2/umount.2.html),
46
+ [umount(8)](https://man7.org/linux/man-pages/man8/umount.8.html)
47
+ - Source: `initramfs/bin/umount` in
48
+ [buninu-linux](https://github.com/jjtseng93/buninu-linux)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "buninu-linux",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A Linux distribution running Bun as PID 1 with the Buninu userspace.",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -37,6 +37,6 @@
37
37
  "fetch": "./index.js -f",
38
38
  "pack": "./index.js -b",
39
39
  "start": "./index.js -r",
40
- "check": "node --check ./index.js && node --check ./initramfs/init.js"
40
+ "check": "for f in ./index.js ./initramfs/init.js ./initramfs/lib/dlopen.js ./initramfs/lib/modprobe.js ./initramfs/bin/mount ./initramfs/bin/umount ./initramfs/bin/ip ./initramfs/bin/poweroff; do node --check \"$f\" || exit 1; done"
41
41
  }
42
42
  }