mirror of
https://github.com/iustin/mt-st.git
synced 2026-06-08 16:22:38 +00:00
Check that the default tape device is a chardev
When using the default tape device (no $TAPE env. var and no explicit tape given), check that it is indeed a character device; this will help with better error messages on systems using udev, where /dev/tape is a directory instead.
This commit is contained in:
11
mt.c
11
mt.c
@@ -319,8 +319,17 @@ main(int argc, char **argv)
|
||||
else
|
||||
break;
|
||||
|
||||
if (tape_name == NULL && (tape_name = getenv("TAPE")) == NULL)
|
||||
if (tape_name == NULL && (tape_name = getenv("TAPE")) == NULL) {
|
||||
struct stat stbuf;
|
||||
|
||||
tape_name = DEFTAPE;
|
||||
if (!stat(tape_name, &stbuf) &&
|
||||
!S_ISCHR(stbuf.st_mode)) {
|
||||
fprintf(stderr, "The default '%s' is not a character device.\n\n", tape_name);
|
||||
usage(1);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (argn >= argc ) {
|
||||
usage(0);
|
||||
|
||||
Reference in New Issue
Block a user