MCPcopy Create free account
hub / github.com/ckb-next/ckb-next / rmdevpath

Function rmdevpath

src/daemon/devnode.c:365–390  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363}
364
365int rmdevpath(usbdevice* kb){
366 euid_guard_start;
367 int index = INDEX_OF(kb, keyboard);
368 if(kb->infifo != 0){
369 int fd = kb->infifo - 1;
370#ifdef OS_MAC
371 fcntl(fd, F_SETFL, O_RDWR | O_NONBLOCK); // hack to prevent the following hack from blocking if the GUI was running
372#endif
373 if (write(fd, "\n", 1) < 0)
374 ckb_warn("Unable to write to filedescriptor %d: %s", fd, strerror(errno));
375 close(fd);
376 kb->infifo = 0;
377 }
378 for(int i = 0; i < OUTFIFO_MAX; i++)
379 _rmnotifynode(kb, i);
380 char path[DEVPATH_LEN + 2];
381 snprintf(path, sizeof(path), "%s%d", devpath, index);
382 if(rm_recursive(path) != 0 && errno != ENOENT){
383 ckb_warn("Unable to delete %s: %s", path, strerror(errno));
384 euid_guard_stop;
385 return -1;
386 }
387 ckb_info("Removed device path %s", path);
388 euid_guard_stop;
389 return 0;
390}
391
392static inline uchar FWBcdToBin(const uchar v){
393 return ((v >> 4) * 10) + (v & 0xF);

Callers 2

closeusbFunction · 0.85
quitFunction · 0.85

Calls 3

_rmnotifynodeFunction · 0.85
rm_recursiveFunction · 0.85
ckb_infoFunction · 0.50

Tested by

no test coverage detected