4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
36 * We don't strip/append partitions on FreeBSD.
40 * Note: The caller must free the returned string.
43 zfs_strip_partition(char *dev)
49 zfs_append_partition(char *path, size_t max_len)
51 return (strnlen(path, max_len));
55 * Strip the path from a device name.
56 * On FreeBSD we only want to remove "/dev/" from the beginning of
60 zfs_strip_path(char *path)
62 if (strncmp(path, _PATH_DEV, sizeof (_PATH_DEV) - 1) == 0)
63 return (path + sizeof (_PATH_DEV) - 1);
69 zfs_get_underlying_path(const char *dev_name)
75 return (realpath(dev_name, NULL));
79 zfs_dev_is_whole_disk(const char *dev_name)
83 fd = g_open(dev_name, 0);
92 * Wait up to timeout_ms for udev to set up the device node. The device is
93 * considered ready when libudev determines it has been initialized, all of
94 * the device links have been verified to exist, and it has been allowed to
95 * settle. At this point the device the device can be accessed reliably.
96 * Depending on the complexity of the udev rules this process could take
100 zpool_label_disk_wait(const char *path, int timeout_ms)
104 hrtime_t start, settle;
105 struct stat64 statbuf;
112 if ((stat64(path, &statbuf) == 0) && (errno == 0)) {
114 settle = gethrtime();
115 else if (NSEC2MSEC(gethrtime() - settle) >= settle_ms)
117 } else if (errno != ENOENT) {
121 usleep(sleep_ms * MILLISEC);
122 } while (NSEC2MSEC(gethrtime() - start) < timeout_ms);
129 is_mpath_whole_disk(const char *path)