Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace libudev backend with sd_device backend #37

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Usb.Events

Subscribe to the Inserted and Removed events to be notified when a USB drive is plugged in or unplugged, or when a USB device is connected or disconnected. Usb.Events is a .NET Standard 2.0 library and uses WMI on Windows, libudev on Linux and IOKit on macOS.
Subscribe to the Inserted and Removed events to be notified when a USB drive is plugged in or unplugged, or when a USB device is connected or disconnected. Usb.Events is a .NET Standard 2.0 library and uses WMI on Windows, libsystemd on Linux and IOKit on macOS.

## How to use:

Expand Down Expand Up @@ -84,7 +84,7 @@ sudo apt-get install build-essential
```
32-bit and 64-bit udev with:
```
sudo apt-get install libudev-dev:i386 libudev-dev:amd64
sudo apt-get install libsystemd0:i386 libsystemd0:amd64
```
support for compiling 32-bit on 64-bit Linux:
```
Expand Down Expand Up @@ -131,9 +131,15 @@ To build 32-bit and 64-bit ARM versions of `UsbEventWatcher.Linux.so` on Windows

- [ ] Automatically mount USB drive on `UsbDeviceAdded` event in Linux
- [ ] Automatically mount USB drive on `UsbDeviceAdded` event in macOS
- [ ] Determine if other operating systems do not display extended info for unplugged devices and update the documentation as necessary

## Version history:

- 11.2.0.1:
- Replaced libudev backend with sd-device backend for Linux clients
- Replace custom linux event loop with libsystemd's sd-event loop
- Update readme
- Explicitly mention that events for unplugged USB devices only return the system name and system path in Linux
- 11.1.0.1:
- Added XML documentation
- 11.1.0.0:
Expand Down
2 changes: 1 addition & 1 deletion Usb.Events/IUsbEventWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace Usb.Events
{
/// <summary>
/// Main Usb.Events interface
/// Monitors USB device insertions and removals, and block device mounts and unmounts.
/// </summary>
public interface IUsbEventWatcher : IDisposable
{
Expand Down
15 changes: 1 addition & 14 deletions Usb.Events/Linux/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,5 @@
"MIMode": "gdb",
"miDebuggerPath": "gdb"
},
{
"name": "Debug UsbEventWatcher.Linux.so",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/../UsbEventWatcher.Linux.so",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "gdb"
}
]
}
}
14 changes: 9 additions & 5 deletions Usb.Events/Linux/Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Compiler options
CC = gcc
CFLAGS = -Wall -Wextra -Werror -pedantic -std=c99 -Wno-unused-parameter
LDFLAGS = -ludev -pthread

# Directories
SRC_DIR = .
OBJ_DIR = obj
BIN_DIR = bin

# Compiler options
CC = gcc
CFLAGS = -Wall -Wextra -Werror -pedantic -std=c99 -Wno-unused-parameter
LDFLAGS = -lsystemd -pthread

# Source files
SRCS = $(wildcard $(SRC_DIR)/*.c)
OBJS = $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SRCS))
DEPS = UsbEventWatcher.Linux.h
EXEC = $(BIN_DIR)/UsbEventWatcher

# Targets
Expand All @@ -23,6 +24,9 @@ $(EXEC): $(OBJS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) -c $< -o $@

$(OBJ_DIR)/UsbEventWatcher.Linux.o: $(DEPS)
$(OBJ_DIR)/main.o: $(DEPS)

debug: CFLAGS += -g
debug: clean all
Expand Down
Loading