Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zpool: allow relative vdev paths #17042

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tonyhutter
Copy link
Contributor

@tonyhutter tonyhutter commented Feb 10, 2025

Motivation and Context

Allow relative paths in zpool create.

Description

zpool create won't let you use relative paths to disks. This is annoying when you want to do:

zpool create tank ./diskfile

But have to do..

zpool create tank `pwd`/diskfile

This fixes it.

How Has This Been Tested?

Manually tested

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

@tonyhutter tonyhutter added Status: Code Review Needed Ready for review and testing good first issue Indicates a good issue for first-time contributors labels Feb 13, 2025
Copy link
Member

@amotin amotin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I worry about safety of this, considering we allow device name specification without the /dev/ prefix. It might create uncertainty. ./file1 might be specific, assuming caller expect this and knows what is his current directory, but some file1 might not.

@tonyhutter
Copy link
Contributor Author

I worry about safety of this, considering we allow device name specification without the /dev/ prefix.

Good point, you could run into trouble if you had a file in your local directory with the same name as a /dev name (like a file called "sda"). How about we require a directory prefix if you're using a local file? Like zpool create tank ./file or zpool create tank ../file would be ok, but zpool create tank file would not?

`zpool create` won't let you use relative paths to disks.  This is
annoying when you want to do:

	zpool create tank ./diskfile

But have to do..

	zpool create tank `pwd`/diskfile

This fixes it.

Signed-off-by: Tony Hutter <[email protected]>
@tonyhutter
Copy link
Contributor Author

Ok, my latest push requires the filename to have a / in it.

@amotin
Copy link
Member

amotin commented Feb 21, 2025

I don't think just / is a sufficient guard, since we often have devices with / in the names, separating type of ID from some ID. I'd specifically check for ./ and ../, or may be some other projects already addressed similar issues and got deeper thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Indicates a good issue for first-time contributors Status: Code Review Needed Ready for review and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants