bluez-tools: Add package bluezetools
[feed/packages.git] / utils / uvol / files / uvol
1 #!/bin/sh
2
3 # uvol prototype
4 # future development roadmap (aka. to-do):
5 # * re-implement in C (use libubox, execve lvm/ubi*)
6 # * hash to validate volume while writing
7 # * add atomic batch processing for use by container/package manager
8
9 if [ -z "$1" ]; then cat <<EOF
10 uvol storage volume manager
11
12 syntax: uvol command ...
13
14 commands:
15 boot get active volumes ready (called on boot)
16 free show number of bytes available
17 total show total number of bytes
18 align show sector size in bytes
19 list [volname] list volumes
20 create volname size type create new volume
21 size: in bytes
22 type: 'ro' or 'rw'
23 remove volname delete volume
24 device volname show block device for mounting
25 size volname show size of volume
26 up volname get volume ready for mounting
27 down volname take volume down after unmounting
28 status volname return status of volume
29 return code: 0 - volume is ready for use
30 1 - volume is not ready for use
31 2 - volume doesn'y exist
32 write volname size write to volume from stdin, size in bytes
33 EOF
34 return 22
35 fi
36
37 uvol_backend=
38 backends_tried=
39
40 for backend in /usr/libexec/uvol/*.sh; do
41 total=$($backend total)
42 backends_tried="$backends_tried $($backend name)"
43 [ "$total" ] && uvol_backend=$backend
44 done
45
46 if [ -z "$uvol_backend" ]; then
47 echo "No backend available. (tried:$backends_tried)"
48 echo "To setup devices with block storage install 'autopart'."
49 return 2
50 fi
51
52 flock -x /tmp/run/uvol.lock "$uvol_backend" "$@"