Can create new files in custom mount but cannot list mount contents

I’m trying to mount an external location to my server. After mounting the location, I can create new files and folders, but getDirectoryListing() always returns an empty array. What am I doing wrong?

$arguments = [
	'datadir' => '/mnt/sda1',

$storage = new \OC\Files\Storage\LocalRootStorage($arguments);
$mount = new \OC\Files\Mount\MountPoint($storage, '/sda1/', $arguments);//, $loader);

// This works and it DOES create the folder

// This always comes back with an empty array

// This throws an error

Lastly, I know that there are apps which allow mounting of external storage devices, but I am trying to do something a little different. This is just an example.

I am not sure, I get the point correctly, but you are trying to develop an app, am I right?

The reason I want to clarify this: If you are working on an app, you should consider the complete namespace prefix \OC as off-limits. It might change without further notification and break the app. Use the official \OCP namespace for whatever you want to achieve.

If you are working on the server code, please forget what I have written above. The complete opposite is more likely there. I cannot help there much, though.

Could you please explain, what your intention is? You just write you want to do it differently. In what sense?


Thanks for your reply, @christianlupus. This is code for the server core. I actually figured out a little more of this on my own and submitted a PR, but I still have a question that no one has answered:

Basically, I managed to create the mount, but I cannot write directly to the mount point and read back the files. I have to create a directory inside the mount and THEN create files inside of that new directory.

For example, say I create the mount point /appdata_[instanceid]. I can write files to that mount point, but I cannot read them back - they aren’t listed when I run getDirectoryListing(). The files DO exist on the filesystem, but the server cannot see them.

Instead, I have to create a directory inside the mount point like /appdata_[instanceid]/appdata_[instanceid]. Then, files can be written and read.

There seems to be some sort of permissions issue, but I’m not sure why. I tried using a permissions wrapper, but it didn’t make any difference. Any thoughts?

Well, I haven’t had any feedback on my PR, but I’d really like to get it approved. If I can just figure out how to write AND read from the root of a new mount (in this case, appdata_[instanceid]), I’ll be golden. However, I’ve spent hours tracing the code and can’t figure out the permissions issues.

If any experts over here see this, your help would be incredibly appreciated.