jvilk / BrowserFS

BrowserFS is an in-browser filesystem that emulates the Node JS filesystem API and supports storing and retrieving files from various backends.
Other
3.06k stars 216 forks source link

Permissions and mode #323

Closed jcubic closed 1 year ago

jcubic commented 2 years ago

I found this in code from fs.stat:

  // @todo Maybe support these? atm, it's a one-user filesystem.
  // user ID of owner
  public uid: number = 0;
  // group ID of owner
  public gid: number = 0;

Is it possible to set this somehow in user code? I plan to (just thinking about right now) implement something like a fake Linux/Unix system and I would like to have in this fake system the architecture of a real Linux system. With users and groups. So it would be great to have this in BrowserFS.

I was thinking about an API that will allow setting this value globally for the whole FS, for the new files but that will also allow changing the file permission.

Actually, I don't think about a real permission system, because BrowserFS works only for one person (single browser tab), I want to mimic real Linux where you have multiple users. So I can have a way to change the user mode of a file.

I also have another question what about mode? is it possible to set it read-only and throw an error when writing? If not then maybe there is a way to change the mode?

I've tested:

fs.chmod("/bar", 0)

but it doesn't throw an error when reading the file.

If this is something like to have in BFS 2.0. I help if I can.

james-pre commented 1 year ago

See #334