fuse-friends / fuse-native

Multithreaded FUSE bindings for Node JS.
203 stars 29 forks source link

Calling fs.readDirSync fails #26

Open 3cooper opened 3 years ago

3cooper commented 3 years ago

I have a file system implemented using Fuse-Native that I can navigate via OS X Finder. I am making a tester for the file system to ensure it works after making changes. I am trying to get the contents of a directory using a script in Node.js, but it is failing.

Example dir: /Users/me/Documents/fusemount/virtualDir

The error: 'EPERM: operation not permitted, scandir '/Users/me/Documents/fusemount/virtualDir'

The code I am using:

  fs.readdirSync('/Users/me/Documents/fusemount/virtualDir').forEach(file => {
    console.log(file);
  });

When I run this I have successful requests for:

  1. access('\')
  2. getAttr('\virtualDir')
  3. getAttr('\')

The debug console shows:

unique: 9, opcode: ACCESS (34), nodeid: 1, insize: 48, pid: 37685
access / 01
   unique: 9, success, outsize: 16
unique: 3, opcode: LOOKUP (1), nodeid: 1, insize: 48, pid: 37685
LOOKUP /virtualDir
getattr /[Mounted Part of Path]
   NODEID: 28
   unique: 3, success, outsize: 160
unique: 4, opcode: GETXATTR (22), nodeid: 28, insize: 71, pid: 0
getxattr /virtualDir com.apple.macl 0 0
   unique: 4, error: -45 (Operation not supported), outsize: 16
unique: 11, opcode: GETATTR (3), nodeid: 1, insize: 56, pid: 37685
getattr /
   unique: 11, success, outsize: 136
unique: 2, opcode: GETXATTR (22), nodeid: 1, insize: 71, pid: 0
getxattr / com.apple.macl 0 0
   unique: 2, error: -45 (Operation not supported), outsize: 16

I have not implemented the following operations:

My statfs operation is returning the same information found in the readme for this project.

getAttr returns the following for folders:

{
  mtime: new Date(2020, 8, 16, 3, 20, 0),
  atime: new Date(2020, 8, 16, 3, 20, 0),
  ctime: new Date(2020, 8, 16, 3, 20, 0),
  nlink: 1,
  size: 100,
  mode: 0o40777,
  uid: process.getuid ? process.getuid() : 0,
  gid: process.getgid ? process.getgid() : 0
};

Any help would be great. Thanks.

3cooper commented 3 years ago

This is somehow caused by running the tests via VSCode. If I run from the command line, I do not get the same issue. Can anyone provide a hint as to why this would be? Is it a permissions thing where VSCode has access to the files but can't run scandir? Makes me wonder if there is something in my return from getAttr return that is causing this.