dev.fron.io rc / f215bfd
packages: add usbreset Tony Olagbaiye a month ago
3 changed file(s) with 82 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 /* usbreset -- send a USB port reset to a USB device */
1
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <fcntl.h>
5 #include <errno.h>
6 #include <sys/ioctl.h>
7
8 #include <linux/usbdevice_fs.h>
9
10
11 int main(int argc, char **argv)
12 {
13 const char *filename;
14 int fd;
15 int rc;
16
17 if (argc != 2) {
18 fprintf(stderr, "Usage: usbreset device-filename\n");
19 return 1;
20 }
21 filename = argv[1];
22
23 fd = open(filename, O_WRONLY);
24 if (fd < 0) {
25 perror("Error opening output file");
26 return 1;
27 }
28
29 printf("Resetting USB device %s\n", filename);
30 rc = ioctl(fd, USBDEVFS_RESET, 0);
31 if (rc < 0) {
32 perror("Error in ioctl");
33 return 1;
34 }
35 printf("Reset successful\n");
36
37 close(fd);
38 return 0;
39 }
0 (define-module (rc packages usbreset)
1 #:use-module (rc packages)
2 #:use-module (guix gexp)
3 #:use-module (guix utils)
4 #:use-module (guix packages)
5 #:use-module (guix download)
6 #:use-module (guix git-download)
7 #:use-module ((guix licenses) #:prefix license:)
8 #:use-module (guix build-system gnu)
9 #:use-module (gnu packages base)
10 #:export (usbreset))
11
12 (define usbreset
13 (package
14 (name "usbreset")
15 (version "0.0.1")
16 (source #f)
17 (build-system gnu-build-system)
18 (arguments
19 '(#:phases
20 (modify-phases %standard-phases
21 (delete 'unpack)
22 (delete 'configure)
23 (replace 'build (lambda* (#:key inputs outputs #:allow-other-keys)
24 (let* ((src (assoc-ref inputs "usbreset.c"))
25 (out (assoc-ref outputs "out"))
26 (bin (string-append out "/bin"))
27 (targ (string-append bin "/usbreset")))
28 (mkdir-p bin)
29 (invoke "gcc" src "-o" targ))))
30 (delete 'install))
31 #:tests? #f))
32 (inputs
33 `(("usbreset.c" ,(local-file "../../data/usbreset.c" "usbreset.c"))))
34 (description "")
35 (synopsis "")
36 (home-page "")
37 (license #f)))
38
39 usbreset
6565 #:use-module (rc packages minecraft)
6666 #:use-module (rc packages nix)
6767 #:use-module (rc packages pipewire)
68 #:use-module (rc packages usbreset)
6869 #:use-module (rc packages xmpppy)
6970 #:use-module (rc packages yggdrasil)
7071 #:export (os))
203204 neovim sshfs tree curl screen jq gvfs wireguard efibootmgr
204205 sway stumpwm awesome xinit xterm setxkbmap rsync gnupg python
205206 fish fish-foreign-env netcat rofi python-wrapper
206 net-tools strace unzip gptfdisk
207 net-tools strace unzip gptfdisk usbreset
207208 font-dejavu font-twitter-emoji font-google-noto font-awesome
208209 %base-packages))
209210