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

actions/image-partition: truncate filesystem label to maximum supported length #271

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

Conversation

vigneshraman
Copy link
Contributor

@vigneshraman vigneshraman commented Jul 27, 2021

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]

Copy link
Member

@obbardc obbardc left a 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."

actions/image_partition_action.go Outdated Show resolved Hide resolved
@vigneshraman vigneshraman force-pushed the vigneshraman/debos/issues/251-v1 branch 2 times, most recently from 24c08d8 to 81b7045 Compare July 27, 2021 07:12
Copy link
Member

@obbardc obbardc left a 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

actions/image_partition_action.go Outdated Show resolved Hide resolved
…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]>
@vigneshraman vigneshraman force-pushed the vigneshraman/debos/issues/251-v1 branch from 81b7045 to aed889e Compare July 27, 2021 07:47
@vigneshraman vigneshraman changed the title actions/image-partition: add optional argument filesystem label and verify length actions/image-partition: truncate filesystem label to maximum supported length Jul 27, 2021
@@ -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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- fslabel -- (optional) Sets the volume name (label) of the filesystem. Defaults
- fslabel -- label for the filesystem. Defaults


switch p.FS {
case "vfat":
maxLength = 11
Copy link
Member

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) ? :-)

Copy link
Member

@obbardc obbardc left a 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
Copy link
Member

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?

@sjoerdsimons
Copy link
Member

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

Copy link
Member

@sjoerdsimons sjoerdsimons left a 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 ;)

@obbardc obbardc added this to the v1.1.4 milestone Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

actions: image-partition: Should check label length in Verify stage
3 participants