Can't access a file in Network Attached Storage (NAS) using C ++ access ()?

I have an Isilon NAS on 10.20.30.11, for example, and I mounted it as follows:

mount 10.20.30.11:/folder /content 

I could use the ls to find the file in the /content folder. Its mod is 777.

 bash-3.00# ls -l /content/a/b/1.txt total 344131 rwxrwxrwx 1 1005 65533 140750 Feb 28 00:58 1.txt 

But I can’t access it with the access () function.

 #include <iostream> #include <string> #include <unistd.h> #include <cerrno> using namespace std; #include <stdio.h> int main( int argc, const char* argv[] ) { int returnVal = 0; returnVal = access(argv[1], R_OK); cout << returnVal << endl; cout << errno << endl; return 0; } 

As a result, it will return -1 and 2, which means "There is no such file or directory."

 ./a.out /content/a/b/1.txt -1 2 #define ENOENT 2 /* No such file or directory */ 

This is not a permission problem, I think, because the mod is 777, and the result is "There is no such file or directory."

+4
source share
2 answers

On the Linux manual pages.

access () may not work correctly on NFS file systems with UID mapping enabled, because UID mapping is performed on the server and hidden from the client, which checks permissions.

+2
source

Finally, it turns out that you need to use the following command to mount Isilon storage.

mount -o vers = 2, proto = tcp 1.2.3.4:/remote/mnt

You must specify the version and protocol.

Thanks!

+1
source

Source: https://habr.com/ru/post/1342066/


All Articles