diff --git a/diskfile.c b/diskfile.c index 6d25670..c1dcf68 100644 --- a/diskfile.c +++ b/diskfile.c @@ -73,6 +73,8 @@ diskfile_open(const char *path, struct fuse_file_info *fi) { return -EACCES; fi->fh = open(entry->source, O_RDONLY); + if (fi->fh == -1) + return -1; return 0; } } diff --git a/linux-size.c b/linux-size.c index 43c9255..5898645 100644 --- a/linux-size.c +++ b/linux-size.c @@ -10,7 +10,10 @@ off_t diskfile_device_size(const char *path) { unsigned long long size; int fd = open(path, O_RDONLY); - ioctl(fd, BLKGETSIZE64, &size); + if (fd == -1) + return 0; + if (ioctl(fd, BLKGETSIZE64, &size) == -1) + size = 0; close(fd); return size; }