]> git.sesse.net Git - bcachefs-tools-debian/blob - mount.bcachefs.sh
Disable pristine-tar option in gbp.conf, since there is no pristine-tar branch.
[bcachefs-tools-debian] / mount.bcachefs.sh
1 #!/bin/bash
2
3 join_by()
4 {
5     local IFS="$1"
6     shift
7     echo "$*"
8 }
9
10 args=$(getopt -u -o 'sfnvo:t:N:' -n 'mount.bcachefs' -- "$@")
11 if [ $? -ne 0 ]; then
12     echo 'Terminating...' >&2
13     exit 1
14 fi
15
16 read -r -a argv <<< "$args"
17
18 for i in ${!argv[@]}; do
19     [[ ${argv[$i]} == '--' ]] && break
20 done
21
22 i=$((i+1))
23
24 if [[ $((i + 2)) < ${#argv[@]} ]]; then
25     echo "Insufficient arguments"
26     exit 1
27 fi
28
29 UUID=${argv[$i]}
30
31 if [[ ${UUID//-/} =~ ^[[:xdigit:]]{32}$ ]]; then
32     PARTS=()
33
34     for part in $(tail -n +3 /proc/partitions|awk '{print $4}'); do
35         uuid_line=$(bcachefs show-super /dev/$part|& head -n1)
36
37         if [[ $uuid_line =~ $UUID ]]; then
38             PARTS+=(/dev/$part)
39         fi
40     done
41
42     if [[ ${#PARTS[@]} == 0 ]]; then
43         echo "uuid $UUID not found"
44         exit 1
45     fi
46
47     argv[$i]=$(join_by : "${PARTS[@]}")
48 fi
49
50 exec mount -i -t bcachefs ${argv[@]}