|
Description
|
Bfu to onnv-gate:2007-07-31, while create pool, if the default mountpoint or
specified by '-m' exist but not empty, it get different behavior while it has file or sub-dir.
I also tried 'zpool import' and found it will import that pool anyway although
it cannot be mounted.
So looks like the behavior a bit inconsistent and need to verify.
# rm -rf /tank/*
(1) has file, the pool just be created but unable to mount
# touch /tank/file0
# zpool create tank c0t0d0s0
cannot mount '/tank': directory is not empty
# echo $?
1
# zpool list
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
tank 68G 94K 68.0G 0% ONLINE -
# zfs mount
(2) has directory, the pool cannot be created.
# zpool destroy tank
# rm -rf /tank/*
# mkdir /tank/dir0
# zpool create tank c0t0d0s0
default mountpoint '/tank' exists and is not empty
use '-m' option to provide a different default
# echo $?
1
# zpool list
no pools available
src/cmd/zpool/zpool_main.c
716 if (stat64(buf, &statbuf) == 0 &&
717 statbuf.st_nlink != 2) {
718 if (mountpoint == NULL)
719 (void) fprintf(stderr, gettext("default "
720 "mountpoint '%s' exists and is not "
721 "empty\n"), buf);
722 else
723 (void) fprintf(stderr, gettext("mountpoint "
724 "'%s' exists and is not empty\n"), buf);
725 (void) fprintf(stderr, gettext("use '-m' "
726 "option to provide a different default\n"));
I believe the only fs-agnostic way to determine if a
directory is empty would be to readdir() it and see if
there are any entries besides "." and ".." -- that's
what we should be doing here. (either that or rmdir()
it and then just rely on the mountpoint creation code
to re-mkdir() it)
|