[Python-Dev] large file support
Sean Reifschneider
jafo@tummy.com
Mon, 17 Jun 2002 21:07:07 -0600
On Mon, Jun 17, 2002 at 11:02:42PM -0400, Guido van Rossum wrote:
>> How about changing os.path.exists for posix to:
>>
>> def exists(path):
>> return(os.access(path, os.F_OK))
>
>NO, NO, NOOOOOOO!
>
>access() does something different. It checks permissions as they
F_OK checks to see if the file exists. Am I misunderstanding something in
the following test:
[2] guin:tmp# cd /tmp
[2] guin:tmp# mkdir test
[2] guin:tmp# chmod 700 test
[2] guin:tmp# touch test/exists
[2] guin:tmp# chmod 700 test/exists
[2] guin:tmp# su -c '/tmp/showaccess /tmp/test/exists' jafo
access: 0 exists: 0
[2] guin:tmp# chmod 111 /tmp/test
[2] guin:tmp# su -c '/tmp/showaccess /tmp/test/exists' jafo
access: 1 exists: 1
[2] guin:tmp# chmod 000 test/exists
[2] guin:tmp# su -c '/tmp/showaccess /tmp/test/exists' jafo
access: 1 exists: 1
[2] guin:tmp# chmod 000 /tmp/test
[2] guin:tmp# su -c '/tmp/showaccess /tmp/test/exists' jafo
access: 0 exists: 0
[2] guin:tmp# su -c '/tmp/showaccess /tmp/test/noexists' jafo
access: 0 exists: 0
[2] guin:tmp# chmod 777 /tmp/test
[2] guin:tmp# su -c '/tmp/showaccess /tmp/test/noexists' jafo
access: 0 exists: 0
The above is run as root, with the su doing the test as non-root. The code
in showaccess simply does an os.access and then an os.path.exists and
displays the results:
[2] guin:tmp# cat /tmp/showaccess
#!/usr/bin/env python2
import os, sys
print 'access: %d exists: %d' % ( os.access(sys.argv[1], os.F_OK),
os.path.exists(sys.argv[1]))
Sean
--
/home is where your .heart is. -- Sean Reifschneider, 1999
Sean Reifschneider, Inimitably Superfluous <jafo@tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python