mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 02:27:36 +03:00
Add zpool_events_seek() functionality
The ZFS_IOC_EVENTS_SEEK ioctl was added to allow user space callers to seek around the zevent file descriptor by EID. When a specific EID is passed and it exists the cursor will be positioned there. If the EID is no longer cached by the kernel ENOENT is returned. The caller may also pass ZEVENT_SEEK_START or ZEVENT_SEEK_END to seek to those respective locations. Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Chris Dunlap <cdunlap@llnl.gov> Issue #2
This commit is contained in:
@@ -3870,6 +3870,42 @@ zpool_events_clear(libzfs_handle_t *hdl, int *count)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Seek to a specific EID, ZEVENT_SEEK_START, or ZEVENT_SEEK_END for
|
||||
* the passed zevent_fd file handle. On success zero is returned,
|
||||
* otherwise -1 is returned and hdl->libzfs_error is set to the errno.
|
||||
*/
|
||||
int
|
||||
zpool_events_seek(libzfs_handle_t *hdl, uint64_t eid, int zevent_fd)
|
||||
{
|
||||
zfs_cmd_t zc = {"\0"};
|
||||
int error = 0;
|
||||
|
||||
zc.zc_guid = eid;
|
||||
zc.zc_cleanup_fd = zevent_fd;
|
||||
|
||||
if (zfs_ioctl(hdl, ZFS_IOC_EVENTS_SEEK, &zc) != 0) {
|
||||
switch (errno) {
|
||||
case ENOENT:
|
||||
error = zfs_error_fmt(hdl, EZFS_NOENT,
|
||||
dgettext(TEXT_DOMAIN, "cannot get event"));
|
||||
break;
|
||||
|
||||
case ENOMEM:
|
||||
error = zfs_error_fmt(hdl, EZFS_NOMEM,
|
||||
dgettext(TEXT_DOMAIN, "cannot get event"));
|
||||
break;
|
||||
|
||||
default:
|
||||
error = zpool_standard_error_fmt(hdl, errno,
|
||||
dgettext(TEXT_DOMAIN, "cannot get event"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (error);
|
||||
}
|
||||
|
||||
void
|
||||
zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
|
||||
char *pathname, size_t len)
|
||||
|
||||
Reference in New Issue
Block a user