Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions cmd/zpool/zpool_vdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,15 +353,32 @@ make_leaf_vdev(nvlist_t *props, const char *arg, boolean_t is_primary)
/*
* Determine whether this is a device or a file.
*/
#if defined(__FreeBSD__)
if (wholedisk) {
/* Devices with geom provider only */
type = VDEV_TYPE_DISK;
} else if (S_ISREG(statbuf.st_mode) ||
S_ISCHR(statbuf.st_mode) || S_ISBLK(statbuf.st_mode)) {
/*
* Regular and devfs files, excluding have geom
* providers. The decision, is it geom provider,
* is made by zfs_dev_is_whole_disk() function.
*/
type = VDEV_TYPE_FILE;
}
#else
if (wholedisk || S_ISBLK(statbuf.st_mode)) {
type = VDEV_TYPE_DISK;
} else if (S_ISREG(statbuf.st_mode)) {
type = VDEV_TYPE_FILE;
} else {
fprintf(stderr, gettext("cannot use '%s': must "
"be a block device or regular file\n"), path);
return (NULL);
}
#endif
}

if (type == NULL) {
fprintf(stderr, gettext("cannot use '%s': must "
"be a block device or regular file\n"), path);
return (NULL);
}

/*
Expand Down
9 changes: 7 additions & 2 deletions include/sys/zfs_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ typedef struct file zfs_file_t;
#endif

typedef struct zfs_file_attr {
uint64_t zfa_size; /* file size */
mode_t zfa_mode; /* file type */
uint64_t zfa_size; /* file size */
mode_t zfa_mode; /* file type */
uint32_t zfa_logical_block_size; /* file logical bs */
uint32_t zfa_physical_block_size; /* file physical bs */
} zfs_file_attr_t;

int zfs_file_open(const char *path, int flags, int mode, zfs_file_t **fp);
Expand All @@ -51,6 +53,9 @@ int zfs_file_read(zfs_file_t *fp, void *buf, size_t len, ssize_t *resid);
int zfs_file_pread(zfs_file_t *fp, void *buf, size_t len, loff_t off,
ssize_t *resid);

void zfs_file_io_strategy(zfs_file_t *fp, void *arg);
void zfs_file_io_strategy_done(zfs_file_t *fp, void *arg);

int zfs_file_seek(zfs_file_t *fp, loff_t *offp, int whence);
int zfs_file_getattr(zfs_file_t *fp, zfs_file_attr_t *zfattr);
int zfs_file_fsync(zfs_file_t *fp, int flags);
Expand Down
32 changes: 32 additions & 0 deletions lib/libzpool/kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,36 @@ zfs_file_seek(zfs_file_t *fp, loff_t *offp, int whence)
return (0);
}

/*
* The file IO strategy routine.
*
* fp - pointer to file (regular, blk or chr)
* arg - data to transfer from/to file, typically ZFS zio
*
* Used only on FreeBSD kernel side for now.
*/
void
zfs_file_io_strategy(zfs_file_t *fp, void *arg)
{
(void) fp;
(void) arg;
}

/*
* The file IO strategy completion routine.
*
* fp - pointer to file (regular, blk or chr)
* arg - data to transfer from/to file, typically ZFS zio
*
* Used only on FreeBSD kernel side for now.
*/
void
zfs_file_io_strategy_done(zfs_file_t *fp, void *arg)
{
(void) fp;
(void) arg;
}

/*
* Get file attributes
*
Expand All @@ -1344,6 +1374,8 @@ zfs_file_getattr(zfs_file_t *fp, zfs_file_attr_t *zfattr)

zfattr->zfa_size = st.st_size;
zfattr->zfa_mode = st.st_mode;
zfattr->zfa_logical_block_size = 0;
zfattr->zfa_physical_block_size = 0;

return (0);
}
Expand Down
17 changes: 13 additions & 4 deletions lib/libzutil/os/freebsd/zutil_device_path_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,23 @@ zfs_get_underlying_path(const char *dev_name)
boolean_t
zfs_dev_is_whole_disk(const char *dev_name)
{
boolean_t wholedisk = B_FALSE;
char *name;
int fd;

fd = g_open(dev_name, 0);
if (fd >= 0) {
g_close(fd);
return (B_TRUE);
if (fd < 0) {
return (B_FALSE);
}
return (B_FALSE);

name = g_providername(fd);
if (name != NULL) {
wholedisk = B_TRUE;
}

g_close(fd);

return (wholedisk);
}

/*
Expand Down
Loading
Loading