Index: /trunk/platform/generic/wrappers.c
===================================================================
--- /trunk/platform/generic/wrappers.c	(revision 1622)
+++ /trunk/platform/generic/wrappers.c	(revision 1623)
@@ -567,9 +567,9 @@
     if (fd>=0) {
         _close(fd);
-        res=_SetFileTimeStamp(file, newTimes->actime , newTimes->modtime);
+        res=_SetFileTimeStamp(file, newTimes->modtime, newTimes->actime);
     }
 #else
     if (fd>=0) {
-        res=_SetFileTimeStamp(fd, newTimes->actime , newTimes->modtime);
+        res=_SetFileTimeStamp(fd, newTimes->modtime, newTimes->actime);
         _close(fd);
     }
Index: /trunk/CHDK/SCRIPTS/TEST/llibtst.lua
===================================================================
--- /trunk/CHDK/SCRIPTS/TEST/llibtst.lua	(revision 1622)
+++ /trunk/CHDK/SCRIPTS/TEST/llibtst.lua	(revision 1623)
@@ -366,11 +366,23 @@
 end
 
-function tstat(name)
+function tstat(name,expect)
 	log('os.stat("',tostring(name),'"): ')
 	local r,msg = os.stat(name)
 	if r then
+		local fail
+		if type(expect) == 'table' then
+			for k,v in pairs(expect) do
+				-- special case, dryos >= R39 doesn't set atime
+				if r[k] ~= v and not (k == 'atime' and r[k] == nil) then
+					logfail("expected "..tostring(k).."="..tostring(v).." not "..tostring(r[k]))
+					fail = true
+				end
+			end
+		end
+		if not fail then
+			logok()
+		end
 --		local keys={ "dev", "ino", "mode", "nlink", "uid", "gid", "rdev", "size", "atime", "mtime", "ctime", "blksize", "blocks", "attrib", "reserved1", "reserved2", "reserved3", "reserved4", "reserved5", "reserved6",}
 		local keys={ "dev", "mode", "size", "atime", "mtime", "ctime", "blksize", "blocks", "attrib","is_dir","is_file",}
-		logok()
 		log("{\n")
 		for _,v in ipairs(keys) do
@@ -443,10 +455,10 @@
 		tf:close()
 		local fn=tdir0..tdat0
-		tstat(fn)
+		tstat(fn,{is_file=true,is_dir=false})
 		tutime(fn) -- utime, current
 		tstat(fn)
-		tutime(fn,os.time({year=1984,month=1,day=1}),os.time({year=1984,month=12,day=25}))
-		tstat(fn)
-		tstat(tdir0)
+		tutime(fn,os.time({year=1984,month=1,day=1,hour=0}),os.time({year=1984,month=12,day=25,hour=0}))
+		tstat(fn,{mtime=os.time({year=1984,month=1,day=1,hour=0}),atime=os.time({year=1984,month=12,day=25,hour=0})})
+		tstat(tdir0,{is_file=false,is_dir=true})
 		tren(tdir0..tdat0,tdir0..tdat1)
 		tlistdir(tdir0)
