2016-12-14 07:37:22

by chendt

[permalink] [raw]
Subject: Opening non-existent file returns different value when O_CREAT|O_DIRECTORY is used

Hi all

On NFSv3, NFSv4 and xfs, opening non-existent file returns different value when
O_CREAT|O_DIRECTORY is used, Is this the right behavior?


TEST LOG:
# cat open_tets.py
#!/bin/python
import posix
fd = posix.open("/mnt/XXXX/file",posix.O_CREAT|posix.O_DIRECTORY, 0777)
print fd
posix.close(fd)

*xfs*
# ./open_test.py
3 -- Create a file and return fd.
# ./open_test.py
Traceback (most recent call last):
File "./open_test.py", line 3, in <module>
fd = posix.open("/mnt/xfs/file",posix.O_CREAT|posix.O_DIRECTORY, 0777)
OSError: [Errno 20] Not a directory: '/mnt/xfs/file'

*NFSv3*
# ./open_test.py
3 -- Create a file and return fd.
# ./open_test.py
Traceback (most recent call last):
File "./open_test.py", line 3, in <module>
fd = posix.open("/mnt/nfsv3/file",posix.O_CREAT|posix.O_DIRECTORY, 0777)
OSError: [Errno 20] Not a directory: '/mnt/nfsv3/file'

*NFSv4.x*
# ./open_test.py
Traceback (most recent call last): -- return ENOENT err directly.
File "./open_test.py", line 3, in <module>
fd = posix.open("/mnt/nfsv4/file",posix.O_CREAT|posix.O_DIRECTORY, 0777)
OSError: [Errno 2] No such file or directory: '/mnt/nfsv4/file'

--




2016-12-14 10:06:31

by Trond Myklebust

[permalink] [raw]
Subject: Re: Opening non-existent file returns different value when O_CREAT|O_DIRECTORY is used

DQo+IE9uIERlYyAxNCwgMjAxNiwgYXQgMDI6MzMsIERpdGFuZyBDaGVuIDxjaGVuZHQuZm5zdEBj
bi5mdWppdHN1LmNvbT4gd3JvdGU6DQo+IA0KPiBIaSBhbGwNCj4gDQo+IE9uIE5GU3YzLCBORlN2
NCBhbmQgeGZzLCBvcGVuaW5nIG5vbi1leGlzdGVudCBmaWxlIHJldHVybnMgZGlmZmVyZW50IHZh
bHVlIHdoZW4gDQo+IE9fQ1JFQVR8T19ESVJFQ1RPUlkgaXMgdXNlZCwgSXMgdGhpcyB0aGUgcmln
aHQgYmVoYXZpb3I/DQo+IA0KDQpUaGF04oCZcyBhbiBpbnZhbGlkIGNvbWJpbmF0aW9uIG9mIE9f
KiBmbGFncyBhbmQgc28gdGhlIGJlaGF2aW91ciBpcyB1bmRlZmluZWQuDQoNCkNoZWVycw0KICBU
cm9uZA==