-
Notifications
You must be signed in to change notification settings - Fork 13
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
Conversation
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…) |
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.
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 |
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.
Is it possible to create this image dynamically as a temp file instead of checking it in?
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.
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
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.
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) => { |
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.
Would it be possible to use simply one fs.open(…, "a")
call here instead nesting of fs.write
/fs.open
?
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.
Fixed
package.json
Outdated
"label-testcase": "nodejs tests/label.js" | ||
}, | ||
"devDependencies": { | ||
"promise-toolbox": "0.15.1" |
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.
See note below on usage.
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.
Fixed
tests/label.js
Outdated
fatfs.createFileSystem(fatfsBuffer(buffer), {allowLowercaseNames: true}) | ||
) | ||
|
||
createLabel("cidata").then(() => { |
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.
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.
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.
Fixed
tests/fatfs-buffer.js
Outdated
@@ -0,0 +1,79 @@ | |||
//From https://github.com/vatesfr/xen-orchestra/blob/9f0b22d3e9c4672d96cb3f63b1e0fd42609e2406/packages/xo-server/src/fatfs-buffer.js |
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.
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?
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.
I think I will replace it with example driver from readme and mkfs (https://superuser.com/a/668534)
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.
Fixed
tests/label.js
Outdated
var fatfsBufferInit = require('./fatfs-buffer').init | ||
var fs = require('fs') | ||
|
||
const buffer = fatfsBufferInit({ label: 'cidata ' }) |
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.
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.
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.
Fixed
I tested this branch and recompiled XO locally and it didn't work. |
Yeah, it should work fine. Could you please provide output of |
Sorry that it took so long. I've fixed PR all comments |
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. |
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 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_' |
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.
should be return cb(e);
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.
Is return
required? I don't think callback has to return anything.
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.
And fixed
D'oh! Sorry to let this one linger, but thanks for cleaning it up if it's no longer needed. |
This PR adds method
createLabel
that will create special file for volume label that will be detected byblkid
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