winnt_stat patch

11 views
Skip to first unread message

Hiroshi Shirosaki

unread,
Aug 3, 2012, 6:47:23 PM8/3/12
to theco...@googlegroups.com
I've updated winnt_stat patch.

Against trunk.
https://gist.github.com/3248001

I've changed the original Dusan's patch to pass test-all.
I added `if (check_valid_dir(path)) return -1;`.

As you may know, original patch didn't pass `assert(!(File.directory?(@dir+"/...")))` in test_file_exhaustive.rb.

check_valid_dir was introduced due to the following issue.

And check_valid_dir was modified due to the following issue.
http://bugs.ruby-lang.org/issues/5819  (File.stat against empty drive's root path fails)


I changed check_valid_dir() less expensive way.


I found a test case of "Fall back to FindFirstFile".

$ ruby -e "p File.stat('//192.168.0.3/c$')"

192.168.0.3 is not existing host. The error of GetFileAttributesEx is ERROR_BAD_NETPATH.

But I'm not sure the reason of adding "Fall back to FindFirstFile".
Do you have any ideas?


And I noticed the following result is different between trunk and patched.
$ ruby -e "p File.stat('/')" 

Patched ruby has atime, mtime and ctime, but trunk ruby doesn't.
It seems due to FindFirstFile doesn't get rootpath info.

# trunk
$ ruby -e "p File.stat('/')"
#<File::Stat dev=0x2, ino=0, mode=040755, nlink=1, uid=0, gid=0, rdev=0x2, size=0, blksize=nil, bloc
ks=nil, atime=1970-01-01 09:00:00 +0900, mtime=1970-01-01 09:00:00 +0900, ctime=1970-01-01 09:00:00
+0900>

I'm thinking to submit this patch to ruby-core. Please Let me know any opinions if you have.

Thank you.

Dušan D. Majkić

unread,
Aug 6, 2012, 10:55:06 AM8/6/12
to theco...@googlegroups.com
> I'm thinking to submit this patch to ruby-core. Please Let me know any
> opinions if you have.

I agree.

Luis Lavena

unread,
Aug 6, 2012, 11:02:36 AM8/6/12
to theco...@googlegroups.com
On Fri, Aug 3, 2012 at 7:47 PM, Hiroshi Shirosaki <h.shi...@gmail.com> wrote:
> I've updated winnt_stat patch.
>
> I found a test case of "Fall back to FindFirstFile".
>
> $ ruby -e "p File.stat('//192.168.0.3/c$')"
>
> 192.168.0.3 is not existing host. The error of GetFileAttributesEx is
> ERROR_BAD_NETPATH.
>
> But I'm not sure the reason of adding "Fall back to FindFirstFile".
> Do you have any ideas?
>

I don't think we should fall back on this case, if we get
ERROR_BAD_NETPATH we should return Errno::ENOENT, like trunk does.

>
> And I noticed the following result is different between trunk and patched.
> $ ruby -e "p File.stat('/')"
>
> Patched ruby has atime, mtime and ctime, but trunk ruby doesn't.
> It seems due to FindFirstFile doesn't get rootpath info.
>

You mean you get 1969-12-31 21:00:00 -0300 or 1970-01-01 09:00:00
+0900, but patch solves that?

>
> I'm thinking to submit this patch to ruby-core. Please Let me know any
> opinions if you have.
>

I think patch is worth it. Please submit. Just last point about *time
proves is good.

> Thank you.

Thanks to you!
--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

Hiroshi Shirosaki

unread,
Aug 6, 2012, 6:34:01 PM8/6/12
to theco...@googlegroups.com
On Tue, Aug 7, 2012 at 12:02 AM, Luis Lavena <luisl...@gmail.com> wrote:
>> And I noticed the following result is different between trunk and patched.
>> $ ruby -e "p File.stat('/')"
>>
>> Patched ruby has atime, mtime and ctime, but trunk ruby doesn't.
>> It seems due to FindFirstFile doesn't get rootpath info.
>>
>
> You mean you get 1969-12-31 21:00:00 -0300 or 1970-01-01 09:00:00
> +0900, but patch solves that?
>

Yes. The patch solves that.


I found jdk patch of stat like function.
http://hg.openjdk.java.net/icedtea/jdk7/jdk/rev/e2d9696aa701

Fallback to FindFirstFile if sharing violations and not root path.
I confirmed GetFileAttributesEx fails against pagefile.sys.

I updated patch for above point.
https://gist.github.com/3278908


It doesn't fallback if GetFileAttributesEx result is ERROR_BAD_NETPATH.
And I added root path check before FindFirstFile.

--
Hiroshi Shirosaki

Hiroshi Shirosaki

unread,
Aug 9, 2012, 7:45:14 AM8/9/12
to theco...@googlegroups.com
I've committed the patch with usa's approval.

https://github.com/ruby/ruby/commit/dcd7f09be26dd85247f58354709e50e97b9c2291

Thank you for comments.

--
Hiroshi Shirosaki
Reply all
Reply to author
Forward
0 new messages