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 fs module utility functions #207

Merged
merged 2 commits into from
Jun 18, 2024
Merged

Add fs module utility functions #207

merged 2 commits into from
Jun 18, 2024

Conversation

nbd168
Copy link
Contributor

@nbd168 nbd168 commented Jun 17, 2024

Implement flock() and ftruncate()

@jow-
Copy link
Owner

jow- commented Jun 17, 2024

Hm, both new functions operate on file handles so they should become methods of fs.file. By current convention, all functions in the fs global namespace operate on paths, but not on open handles.

User who wish to use those functions with raw descriptor numbers might use:

let fd = 123;
let fp = fs.fdopen(fd);

fp.truncate();
fp.flock("x");

Or more concise:
fs.fdopen(123).truncate()

nbd168 added 2 commits June 17, 2024 12:52
Trunates the file referenced by a file handle

Signed-off-by: Felix Fietkau <[email protected]>
Implements file based locking on a given file handle.

Signed-off-by: Felix Fietkau <[email protected]>
@nbd168
Copy link
Contributor Author

nbd168 commented Jun 18, 2024

Is it fine now?

@jow-
Copy link
Owner

jow- commented Jun 18, 2024

Yes, LGTM!

@jow- jow- merged commit 5c26244 into jow-:master Jun 18, 2024
6 checks passed
@nbd168 nbd168 deleted the fs branch October 24, 2024 09:06
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.

2 participants