Add access() test to KISS device configuration
Add access() test to KISS device configuration, providing a formatted error message to present upon failure
This commit is contained in:
parent
d2fc96a777
commit
595a58f32a
1 changed files with 6 additions and 0 deletions
6
bin/if.c
6
bin/if.c
|
@ -2,6 +2,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <patty/ax25.h>
|
#include <patty/ax25.h>
|
||||||
|
@ -62,6 +63,11 @@ static patty_ax25_if *create_kiss(struct context *ctx, int argc, char **argv) {
|
||||||
for (i=0; i<argc; i++) {
|
for (i=0; i<argc; i++) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case MODE_KISS_DEVICE:
|
case MODE_KISS_DEVICE:
|
||||||
|
if (access(argv[i], R_OK | W_OK) < 0) {
|
||||||
|
patty_error_fmt(ctx->err, "Unable to access device %s: %s",
|
||||||
|
argv[i], strerror(errno));
|
||||||
|
}
|
||||||
|
|
||||||
info.flags |= PATTY_KISS_TNC_DEVICE;
|
info.flags |= PATTY_KISS_TNC_DEVICE;
|
||||||
info.device = argv[i];
|
info.device = argv[i];
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue