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

Add method for creating volume label #31

Closed
wants to merge 9 commits into from
Closed

Add method for creating volume label #31

wants to merge 9 commits into from

Conversation

andrzejressel
Copy link

@andrzejressel andrzejressel commented Jun 13, 2020

This PR adds method createLabel that will create special file for volume label that will be detected by blkid after latest changes.

I've tested it with my fork of Xen Orchestra: https://github.com/jereksel/xen-orchestra/tree/label and Ubuntu 20.04

Fixes #30

@andrzejressel andrzejressel changed the title Add method for create volume label Add method for creating volume label Jun 14, 2020
@natevw
Copy link
Owner

natevw commented Jun 30, 2020

Hi sorry for the delay on this. I think this is a good start and a reasonable approach overall, but have lots of specific feedback I'll add on the PR itself soon. (About to hop on yet another meeting call…)

Copy link
Owner

@natevw natevw left a comment

Choose a reason for hiding this comment

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

Thanks much for this PR and including tests. Provided lots of feedback on some of the details but hopefully those are easy fixes and the core technique relying on fs._updateEntry looks good to me!

.gitignore Outdated
@@ -1,3 +1,5 @@
.DS_Store
.vscode/
node_modules/
package-lock.json
label.img
Copy link
Owner

Choose a reason for hiding this comment

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

Is it possible to create this image dynamically as a temp file instead of checking it in?

Copy link
Owner

Choose a reason for hiding this comment

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

Oh silly me… was in a hurry and not realizing this was in the .gitignore and the whole point is that this is a temp file that is not getting tracked. Consider changing to the explicit path expected though? tests/label.img

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

index.js Outdated
@@ -557,6 +557,22 @@ exports.createFileSystem = function (volume, opts, cb) {
else _.delayedCall(cb, S.err.NOSYS());
}, (_n_ === '_nested_')); };

fs.createLabel = function (name, cb) {
fs.writeFile(name, "", () => {
fs.open(name, "w", (e,_fd) => {
Copy link
Owner

Choose a reason for hiding this comment

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

Would it be possible to use simply one fs.open(…, "a") call here instead nesting of fs.write/fs.open?

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

package.json Outdated
"label-testcase": "nodejs tests/label.js"
},
"devDependencies": {
"promise-toolbox": "0.15.1"
Copy link
Owner

Choose a reason for hiding this comment

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

See note below on usage.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

tests/label.js Outdated
fatfs.createFileSystem(fatfsBuffer(buffer), {allowLowercaseNames: true})
)

createLabel("cidata").then(() => {
Copy link
Owner

Choose a reason for hiding this comment

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

I don't think it's worth bringing in a new dependency just for one call. Please match the "old school" callback style used by the rest of the project here.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@@ -0,0 +1,79 @@
//From https://github.com/vatesfr/xen-orchestra/blob/9f0b22d3e9c4672d96cb3f63b1e0fd42609e2406/packages/xo-server/src/fatfs-buffer.js
Copy link
Owner

Choose a reason for hiding this comment

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

Is this code restricted by the AGPL3 license then, or is its author willing to contribute it under the MIT/Apache terms of this library?

Copy link
Author

Choose a reason for hiding this comment

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

I think I will replace it with example driver from readme and mkfs (https://superuser.com/a/668534)

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

tests/label.js Outdated
var fatfsBufferInit = require('./fatfs-buffer').init
var fs = require('fs')

const buffer = fatfsBufferInit({ label: 'cidata ' })
Copy link
Owner

Choose a reason for hiding this comment

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

My understanding was that the buffer code from the xen-orchestra was a workaround before the createLabel method you're adding. So is it possible that passing in the same "cidata" label here will mask failures of the new method itself? Consider passing a recognizable "wrong" label here instead.

Copy link
Author

Choose a reason for hiding this comment

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

Fixed

@marlluslustosa
Copy link

I tested this branch and recompiled XO locally and it didn't work.
Is that functional?

@andrzejressel
Copy link
Author

I tested this branch and recompiled XO locally and it didn't work.
Is that functional?

Yeah, it should work fine. Could you please provide output of blkid /dev/cdrom and dosfslabel /dev/cdrom. I think you could also try to debug cloud-init. I can't remember how I've done it, but you can invoke only source search.

@andrzejressel
Copy link
Author

Sorry that it took so long. I've fixed PR all comments

@marlluslustosa
Copy link

Cool. I am currently working to fix this on cloudinit. I have now sent patch patches to cloudinit both to see LABEL and LABEL_FATBOOT in their own scripts.

I hope to see this resolved by both parties as soon as possible.
You can check my update here: https://bugs.launchpad.net/cloud-init/+bug/1841466/comments/5
thanks!

Copy link
Owner

@natevw natevw left a comment

Choose a reason for hiding this comment

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

Looking good, just one hopefully final bit of feedback!

index.js Outdated
fs.createLabel = function (name, cb) {
fs.open(name, "a", (e,_fd) => {
if (e) {
throw '_open_error_'
Copy link
Owner

Choose a reason for hiding this comment

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

should be return cb(e);

Copy link
Author

Choose a reason for hiding this comment

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

Is return required? I don't think callback has to return anything.

Copy link
Author

Choose a reason for hiding this comment

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

And fixed

@andrzejressel andrzejressel deleted the label branch May 30, 2023 21:51
@natevw
Copy link
Owner

natevw commented May 30, 2023

D'oh! Sorry to let this one linger, but thanks for cleaning it up if it's no longer needed.

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.

Changes in "util-linux" (blkid) -> LABEL vs. LABEL_FATBOOT
3 participants