Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Implement missing Fs functions #799

Closed
creationix opened this issue Mar 16, 2011 · 9 comments
Closed

Implement missing Fs functions #799

creationix opened this issue Mar 16, 2011 · 9 comments

Comments

@creationix
Copy link

While implementing the sftp protocol, I noticed that node is missing a few posix fs wrappers.

https://github.com/creationix/sftp-server

  • setstat and fsetstat - these are used to set the mtime and other stat properties on a file by either path or fd. We have chmod, but it can only modify the permission bit, I need to be able to change any part of the stat data.
  • opendir, readdir, closedir - I need to be able to open a directory like a file. I first need a fd, then I need to be able to read the listing a chunk at a time, and then close the file descriptor.
@isaacs
Copy link

isaacs commented Mar 17, 2011

opendir, readdir, closedir are all abstracted into fs.readdir

setstat and fsetstat +1 though. :)

On Wed, Mar 16, 2011 at 16:56, creationix
reply@reply.github.com
wrote:

While implementing the sftp protocol, I noticed that node is missing a few posix fs wrappers.

https://github.com/creationix/sftp-server

 - setstat and fsetstat - these are used to set the mtime and other stat properties on a file by either path or fd.  We have chmod, but it can only modify the permission bit, I need to be able to change any part of the stat data.

 - opendir, readdir, closedir - I need to be able to open a directory like a file.  I first need a fd, then I need to be able to read the listing a chunk at a time, and then close the file descriptor.

Reply to this email directly or view it on GitHub:
#799

@creationix
Copy link
Author

I realize they are abstracted for readdir, but I need the low level ones for the sftp protocol or else I have to buffer it all and create a fake fd and basically unabstract it.

@creationix
Copy link
Author

Also I don't know the posix side very well. I was able to open a directory with the normal open command, but the read function didn't want to work on a directory. So maybe we can reuse open and close, but just have another version of read that works on directory handles.

@isaacs
Copy link

isaacs commented Mar 17, 2011

I believe that directory FDs and file FDs are different animals.

A low-level readdir binding would be good. Maybe fs.readdir() could
take either an int or a string, and do the abstracted thing if it's
given a path, and the lowlevel thing if it's not.

It is a bit odd that fs.readdir is the only one with a posix name that
doesn't match its posix cousin.

On Wed, Mar 16, 2011 at 17:10, creationix
reply@reply.github.com
wrote:

Also I don't know the posix side very well.  I was able to open a directory with the normal open command, but the read function didn't want to work on a directory.  So maybe we can reuse open and close, but just have another version of read that works on directory handles.

Reply to this email directly or view it on GitHub:
#799 (comment)

@creationix
Copy link
Author

Sounds good, do I need to come up with a patch to get this done, or can you and/or Ryan implement it?

@ry
Copy link

ry commented Mar 17, 2011

creationix - i'm not against a directory streaming api - but we need to figure out how it looks. we're not going to get to this for a while - so feel free

@creationix
Copy link
Author

The only thing I need to finish my sftp server is fsetstat and setstat, those should be pretty straight-forward. I can wait on the streaming directory reader.

@creationix
Copy link
Author

Isaac pointed out that trunk node now has utimes and futimes. I think all I need now is fchmod and fchown to finish out fsetstat. (I'm setting uid, gid, permissions, mtime, and atime)

@isaacs
Copy link

isaacs commented Mar 29, 2011

Moved to #853. Closing this.

@isaacs isaacs closed this as completed Mar 29, 2011
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants