static int
check_slice(const char *path, blkid_cache cache, int force, boolean_t isspare)
{
- struct stat64 statbuf;
int err;
#ifdef HAVE_LIBBLKID
char *value;
-#endif /* HAVE_LIBBLKID */
-
- if (stat64(path, &statbuf) != 0) {
- vdev_error(gettext("cannot stat %s: %s\n"),
- path, strerror(errno));
- return (-1);
- }
-#ifdef HAVE_LIBBLKID
/* No valid type detected device is safe to use */
value = blkid_get_tag_value(cache, "TYPE", path);
if (value == NULL)
/*
* This may be a shorthand device path or it could be total gibberish.
- * Check to see if it's a known device in /dev/, /dev/disk/by-id,
- * /dev/disk/by-label, /dev/disk/by-path, /dev/disk/by-uuid, or
- * /dev/disk/zpool/. As part of this check, see if we've been given
- * an entire disk (minus the slice number).
+ * Check to see if it is a known device available in zfs_vdev_paths.
+ * As part of this check, see if we've been given an entire disk
+ * (minus the slice number).
*/
static int
is_shorthand_path(const char *arg, char *path,
struct stat64 *statbuf, boolean_t *wholedisk)
{
- if (zfs_resolve_shortname(arg, path, MAXPATHLEN) == 0) {
+ int error;
+
+ error = zfs_resolve_shortname(arg, path, MAXPATHLEN);
+ if (error == 0) {
*wholedisk = is_whole_disk(path);
if (*wholedisk || (stat64(path, statbuf) == 0))
return (0);
memset(statbuf, 0, sizeof(*statbuf));
*wholedisk = B_FALSE;
- return (ENOENT);
+ return (error);
}
/*
* device, fill in the device id to make a complete nvlist. Valid forms for a
* leaf vdev are:
*
- * /dev/xxx Complete disk path
- * /xxx Full path to file
- * xxx Shorthand for /dev/disk/yyy/xxx
+ * /dev/xxx Complete disk path
+ * /xxx Full path to file
+ * xxx Shorthand for <zfs_vdev_paths>/xxx
*/
static nvlist_t *
-make_leaf_vdev(const char *arg, uint64_t is_log)
+make_leaf_vdev(nvlist_t *props, const char *arg, uint64_t is_log)
{
char path[MAXPATHLEN];
struct stat64 statbuf;
verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_WHOLE_DISK,
(uint64_t)wholedisk) == 0);
+ if (props != NULL) {
+ uint64_t ashift = 0;
+ char *value = NULL;
+
+ if (nvlist_lookup_string(props,
+ zpool_prop_to_name(ZPOOL_PROP_ASHIFT), &value) == 0)
+ zfs_nicestrtonum(NULL, value, &ashift);
+
+ if (ashift > 0)
+ verify(nvlist_add_uint64(vdev, ZPOOL_CONFIG_ASHIFT,
+ ashift) == 0);
+ }
+
return (vdev);
}
* deletes and recreates the link during which access attempts
* will fail with ENOENT.
*/
- zfs_append_partition(path, udevpath, sizeof (udevpath));
+ strncpy(udevpath, path, MAXPATHLEN);
+ (void) zfs_append_partition(udevpath, MAXPATHLEN);
+
if ((strncmp(udevpath, UDISK_ROOT, strlen(UDISK_ROOT)) == 0) &&
(lstat64(udevpath, &statbuf) == 0) &&
S_ISLNK(statbuf.st_mode))
}
/*
- * Update the path to refer to FIRST_SLICE. The presence of
+ * Update the path to refer to the partition. The presence of
* the 'whole_disk' field indicates to the CLI that we should
- * chop off the slice number when displaying the device in
+ * chop off the partition number when displaying the device in
* future output.
*/
verify(nvlist_add_string(nv, ZPOOL_CONFIG_PATH, udevpath) == 0);
* because the program is just going to exit anyway.
*/
nvlist_t *
-construct_spec(int argc, char **argv)
+construct_spec(nvlist_t *props, int argc, char **argv)
{
nvlist_t *nvroot, *nv, **top, **spares, **l2cache;
int t, toplevels, mindev, maxdev, nspares, nlogs, nl2cache;
children * sizeof (nvlist_t *));
if (child == NULL)
zpool_no_memory();
- if ((nv = make_leaf_vdev(argv[c], B_FALSE))
+ if ((nv = make_leaf_vdev(props, argv[c], B_FALSE))
== NULL)
return (NULL);
child[children - 1] = nv;
* We have a device. Pass off to make_leaf_vdev() to
* construct the appropriate nvlist describing the vdev.
*/
- if ((nv = make_leaf_vdev(argv[0], is_log)) == NULL)
+ if ((nv = make_leaf_vdev(props, argv[0], is_log)) == NULL)
return (NULL);
if (is_log)
nlogs++;
uint_t c, children;
if (argc > 0) {
- if ((newroot = construct_spec(argc, argv)) == NULL) {
+ if ((newroot = construct_spec(props, argc, argv)) == NULL) {
(void) fprintf(stderr, gettext("Unable to build a "
"pool from the specified devices\n"));
return (NULL);
* added, even if they appear in use.
*/
nvlist_t *
-make_root_vdev(zpool_handle_t *zhp, int force, int check_rep,
+make_root_vdev(zpool_handle_t *zhp, nvlist_t *props, int force, int check_rep,
boolean_t replacing, boolean_t dryrun, int argc, char **argv)
{
nvlist_t *newroot;
* that we have a valid specification, and that all devices can be
* opened.
*/
- if ((newroot = construct_spec(argc, argv)) == NULL)
+ if ((newroot = construct_spec(props, argc, argv)) == NULL)
return (NULL);
if (zhp && ((poolconfig = zpool_get_config(zhp, NULL)) == NULL))