http://bugzilla.novell.com/show_bug.cgi?id=494253


           Summary: Mono.Unix.Native.Syscall.utimes, .lutimes, .futimes
                    use atime as mtime
    Classification: Mono
           Product: Mono: Class Libraries
           Version: SVN
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Mono.POSIX
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
          Found By: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.8)
Gecko/2009032609 Firefox/3.0.8 (.NET CLR 3.5.30729)

In the Mono.Unix.Native.Syscall class, in at least 2.0.1 through SVN, the
functions utimes, lutimes, and futimes all have the same bug.  In accordance
with the documentation for the respective system calls, they each take a
Timeval[] which is expected to have length 2, the first being the atime (last
access time) and the second being the mtime (last write time).  However, they
actually set both the atime and the mtime to the time specified by the first
entry in the array.

A glance at the source code in SVN makes it pretty clear that the problem is in
support/sys-time.c in the function copy_utimes, which is used by all 3 of these
functions:

static inline struct timeval*
copy_utimes (struct timeval* to, struct Mono_Posix_Timeval *from)
{
        if (from) {
                to[0].tv_sec  = from->tv_sec;
                to[0].tv_usec = from->tv_usec;
                to[1].tv_sec  = from->tv_sec;    //< WRONG
                to[1].tv_usec = from->tv_usec;   //< WRONG
                return to;
        }

        return NULL;
}

I would change this to

static inline struct timeval*
copy_utimes (struct timeval* to, struct Mono_Posix_Timeval *from)
{
        if (from) {
                to[0].tv_sec  = from[0].tv_sec;
                to[0].tv_usec = from[0].tv_usec;
                to[1].tv_sec  = from[1].tv_sec;    //< WRONG
                to[1].tv_usec = from[1].tv_usec;   //< WRONG
                return to;
        }

        return NULL;
}

Reproducible: Always

Steps to Reproduce:
// C# code snippet

string path = "t.txt";
var times = new Mono.Unix.Native.Timeval[] { 
    new Mono.Unix.Native.Timeval { tv_sec = 1000 * 1000000 },
    new Mono.Unix.Native.Timeval { tv_sec = 1100 * 1000000 } };
if (Mono.Unix.Native.Syscall.lutimes(path, times) != 0)
    throw new IOException("Failed to set utimes for " + path + ".", new
Mono.Unix.UnixIOException());

// Then stat t.txt at the command line
Actual Results:  
Access: 2001-09-09 01:46:40.000000000 +0000
Modify: 2001-09-09 01:46:40.000000000 +0000
Change: 2009-04-13 03:14:31.284572623 +0000


Expected Results:  
Access: 2001-09-09 01:46:40.000000000 +0000
Modify: 2004-11-09 11:33:20.000000000 +0000
Change: 2009-04-13 03:14:31.284572623 +0000

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to