Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
GCC=@gcc
CFLAGS=-Wall -pedantic `pkg-config --cflags blockdev glib-2.0`
CLIBS=`pkg-config --libs blockdev glib-2.0` -lbd_utils -lm
BD_CFLAGS=-Wall -pedantic `pkg-config --cflags blockdev blockdev-utils glib-2.0`
BD_CLIBS=`pkg-config --libs blockdev blockdev-utils glib-2.0` -lm
UDISKS_CFLAGS=-Wall -pedantic `pkg-config --cflags udisks2 udisks2-lvm2 gio-2.0 glib-2.0`
UDISKS_CLIBS=`pkg-config --libs udisks2 udisks2-lvm2 gio-2.0 glib-2.0`
RM=@rm -rf

default: demo-1-libblockdev demo-1-progress
default: demo-1-libblockdev demo-1-progress demo-1-libudisks

clean:
$(RM) demo-1-libblockdev demo-1-progress
$(RM) demo-1-libblockdev demo-1-progress demo-1-libudisks

demo-1-libblockdev:
$(GCC) $(CFLAGS) $(CLIBS) -o demo-1-libblockdev demo-1-libblockdev.c
$(GCC) $(BD_CFLAGS) $(BD_CLIBS) -o demo-1-libblockdev demo-1-libblockdev.c
demo-1-progress:
$(GCC) $(CFLAGS) $(CLIBS) -o demo-1-progress demo-1-progress.c
$(GCC) $(BD_CFLAGS) $(BD_CLIBS) -o demo-1-progress demo-1-progress.c
demo-1-libudisks:
$(GCC) $(UDISKS_CFLAGS) $(UDISKS_CLIBS) -o demo-1-libudisks demo-1-libudisks.c
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
# api-examples
Examples of how the various APIs from the project can be utilized

Examples of how the various storage APIs from the [storaged-project](https://github.com/storaged-project) can be utilized.

Most examples demonstrate the same workflow -- creating an encrypted LVM setup on two disks:

1. Wipe existing disk signatures
2. Create LVM physical volumes on two disks
3. Create a volume group combining the two PVs
4. Create a swap logical volume and run mkswap
5. Create a data logical volume and encrypt it with LUKS2
6. Format the encrypted volume with XFS
7. Clean up by removing all created devices

`demo-1-progress.c` is a standalone example demonstrating libblockdev's progress reporting by running e2fsck on an ext4 filesystem with a progress callback.

## Examples

### C

| File | Library | Description |
|------|---------|-------------|
| `demo-1-libblockdev.c` | [libblockdev](https://github.com/storaged-project/libblockdev) | Direct library calls for storage management |
| `demo-1-progress.c` | [libblockdev](https://github.com/storaged-project/libblockdev) | Progress reporting with callbacks (runs e2fsck with progress) |
| `demo-1-libudisks.c` | [libudisks](https://github.com/storaged-project/udisks) | Storage management via the UDisks2 daemon (D-Bus) |

### Python

| File | Library | Description |
|------|---------|-------------|
| `demo-1-libblockdev-python` | [libblockdev](https://github.com/storaged-project/libblockdev) | Python bindings for libblockdev via GObject introspection |
| `demo-1-blivet` | [Blivet](https://github.com/storaged-project/blivet) | High-level declarative storage configuration |
| `demo-1-udisks-dbus` | [UDisks2](https://github.com/storaged-project/udisks) | Direct D-Bus calls to the UDisks2 daemon |

## License

MIT
Loading