Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2012-06-22
20:01 • Closed ticket [2935503fff]: Incorrect mode field returned by file stat command</... artifact: dfcf82b4f6 user: nijtmans
2011-10-13
15:04 • Pending ticket [2935503fff]. artifact: af678e9d12 user: nijtmans
01:53 • Ticket [2935503fff]: 4 changes artifact: 1efaee618b user: andreas_kupries
01:46 • Open ticket [2935503fff]. artifact: c3bde7acd5 user: dgp
01:43 • Ticket [2935503fff]: 4 changes artifact: cc4997b33e user: dgp
00:24 • Ticket [2935503fff]: 4 changes artifact: 48289159ac user: dgp
2011-10-11
20:39 • Pending ticket [2935503fff]. artifact: 1134f8e03d user: nijtmans
2011-08-25
22:21 • Ticket [2935503fff]: 5 changes artifact: 2f989fbd1d user: apnadkarni
2010-01-20
09:25 • New ticket [2935503fff]. artifact: 919e3a1335 user: apnadkarni

Incorrect mode field returned by file stat command

Closed / Fixed2935503fffffffffffffffffffffffffffffffffCreated 17 years agoUpdated 14 years ago
Descriptionplain2010-01-20 09:25:12
From c.l.t  posting by keithv -
----
Is the mode value from file stat meaningful on Windows.
Under tcl 8.5, it always seems to return 0644
even if you have permission write to the file.

(This problem came up when I was trying to figure
out why tcllib's ftpd package wouldn't let me delete
a file.)

Thanks,
Keith 
----

Looking at the code, the problem is in the NativeStatMode function in tclWinFile.c
The lines propagating the owner bits to group and others -
    mode |= (mode & 0x0700) >> 3;
    mode |= (mode & 0x0700) >> 6;
should be
    mode |= (mode & 0700) >> 3;
    mode |= (mode & 0700) >> 6;

(i.e. octal 700, not hex)

/Ashok
apnadkarniplain2011-08-25 22:21:49
Reassigned to dgp as per instruction from him
nijtmansplain2011-10-11 20:39:22
This one is so trivial, just let's fix it.....

Test io-40.2, which was previously unix-only
adapted to show how valid this bug report is.

Fixed in all open branches.
dgpplain2011-10-13 00:24:34
Test fails in a tcl/unix build on OSX Snow Leopard:


==== io-40.2 POSIX open access modes: CREAT FAILED
==== Contents of test case:

    file delete $path(test3)
    set f [open $path(test3) {WRONLY CREAT} 0o666]
    file stat $path(test3) stats
    set x [format "0o%o" [expr $stats(mode)&0o777]]
    puts $f "line 1"
    close $f
    set f [open $path(test3) r]
    lappend x [gets $f]
    close $f
    set x

---- Result was:
0o644 {line 1}
---- Result should have been (exact matching):
0o666 {line 1}
==== io-40.2 FAILED
dgpplain2011-10-13 01:43:15
Same failure on Centos system.
dgpplain2011-10-13 01:46:55
Just because we ask for permissions 0o666
doesn't mean we'll get them depending on
what permissions we have on the containing dir.
andreas_kupriesplain2011-10-13 01:53:39
And the user's 'umask' settings in the current shell may effect results too.
nijtmansplain2011-10-13 15:04:21
Reverting test-case, als the actual change is Windows-only anyway.

So it was not that trivial.......
nijtmansplain2012-06-22 20:01:56
allow_comments - 1
Log in (anonymous is fine) to add a comment.