Changeset View
Changeset View
Standalone View
Standalone View
head/usr.sbin/bhyve/block_if.c
Show All 31 Lines | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/queue.h> | #include <sys/queue.h> | ||||
#include <sys/errno.h> | #include <sys/errno.h> | ||||
#include <sys/stat.h> | #include <sys/stat.h> | ||||
#include <sys/ioctl.h> | #include <sys/ioctl.h> | ||||
#include <sys/disk.h> | #include <sys/disk.h> | ||||
#include <assert.h> | #include <assert.h> | ||||
#include <err.h> | |||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <stdlib.h> | #include <stdlib.h> | ||||
#include <string.h> | #include <string.h> | ||||
#include <pthread.h> | #include <pthread.h> | ||||
#include <pthread_np.h> | #include <pthread_np.h> | ||||
#include <signal.h> | #include <signal.h> | ||||
#include <unistd.h> | #include <unistd.h> | ||||
▲ Show 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | blockif_open(const char *optstr, const char *ident) | ||||
fd = open(nopt, (ro ? O_RDONLY : O_RDWR) | extra); | fd = open(nopt, (ro ? O_RDONLY : O_RDWR) | extra); | ||||
if (fd < 0 && !ro) { | if (fd < 0 && !ro) { | ||||
/* Attempt a r/w fail with a r/o open */ | /* Attempt a r/w fail with a r/o open */ | ||||
fd = open(nopt, O_RDONLY | extra); | fd = open(nopt, O_RDONLY | extra); | ||||
ro = 1; | ro = 1; | ||||
} | } | ||||
if (fd < 0) { | if (fd < 0) { | ||||
perror("Could not open backing file"); | warn("Could not open backing file: %s", nopt); | ||||
goto err; | goto err; | ||||
} | } | ||||
if (fstat(fd, &sbuf) < 0) { | if (fstat(fd, &sbuf) < 0) { | ||||
perror("Could not stat backing file"); | warn("Could not stat backing file %s", nopt); | ||||
goto err; | goto err; | ||||
} | } | ||||
/* | /* | ||||
* Deal with raw devices | * Deal with raw devices | ||||
*/ | */ | ||||
size = sbuf.st_size; | size = sbuf.st_size; | ||||
sectsz = DEV_BSIZE; | sectsz = DEV_BSIZE; | ||||
▲ Show 20 Lines • Show All 357 Lines • Show Last 20 Lines |