-
Notifications
You must be signed in to change notification settings - Fork 140
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
actions/image-partition: truncate filesystem label to maximum supported length #271
base: main
Are you sure you want to change the base?
actions/image-partition: truncate filesystem label to maximum supported length #271
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking at it properly; we may as well squash these two comments
also add rationale to adding seperate fslabel
property in commit message. Something like "Added optional fslabel
property to partition
to allow truncation of filesystem label and allow user to modify filesystem label without modifying the name."
24c08d8
to
81b7045
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also change commit and PR title to something more descriptive; like actions/image-partition: truncate filesystem label to max supported length
…ed length Added optional fslabel property to partition to allow truncation of filesystem label and allow user to modify filesystem label without modifying the name. Filesystem label defaults to the name property of the partition. The filesystem label can be up to 11 characters long for vfat, 16 characters long for ext2/3/4, 255 characters long for btrfs, 512 characters long for hfs/hfsplus and 12 characters long for xfs. Any longer labels will be automatically truncated. Fixes: go-debos#251 Suggested-by: Christopher Obbard <[email protected]> Signed-off-by: Vignesh Raman <[email protected]>
81b7045
to
aed889e
Compare
@@ -72,6 +73,12 @@ Optional properties: | |||
- partlabel -- label for the partition in the GPT partition table. Defaults | |||
to the `name` property of the partition. May only be used for GPT partitions. | |||
|
|||
- fslabel -- (optional) Sets the volume name (label) of the filesystem. Defaults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- fslabel -- (optional) Sets the volume name (label) of the filesystem. Defaults | |
- fslabel -- label for the filesystem. Defaults |
|
||
switch p.FS { | ||
case "vfat": | ||
maxLength = 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also warn if someone tries to set an fslabel for an unsupported fs (but ignore none
type) ? :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of nits.
if maxLength > 0 && len(p.FSLabel) > maxLength { | ||
truncated := p.FSLabel[0:maxLength] | ||
log.Printf("Warning: fs label for %s '%s' is too long; truncated to '%s'", p.Name, p.FSLabel, truncated) | ||
p.FSLabel = truncated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why truncate rather then erroring out?
fwiw this should really just check the name length in verify to error out early if the name is too long; the seperate fslabel doesn't really have a point, if you want to differentiate the partitation label and filesystem labet there is already partlabel for that.. And there really is no point in setting the name to different values other then using it in one of the labels |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fail don't truncate as noted in my lsat comment ;)
Added optional fslabel property to partition to allow truncation of filesystem
label and allow user to modify filesystem label without modifying the name.
Filesystem label defaults to the name property of the partition.
The filesystem label can be up to 11 characters long for vfat, 16 characters
long for ext2/3/4, 255 characters long for btrfs, 512 characters long for
hfs/hfsplus and 12 characters long for xfs. Any longer labels will be
automatically truncated.
Fixes: #251
Suggested-by: Christopher Obbard [email protected]
Signed-off-by: Vignesh Raman [email protected]