public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [Linux-ia64] utime emulation
@ 2002-08-06 19:01 Wichmann, Mats D
  2002-08-06 20:23 ` David Mosberger
  2002-08-06 20:40 ` Andreas Schwab
  0 siblings, 2 replies; 3+ messages in thread
From: Wichmann, Mats D @ 2002-08-06 19:01 UTC (permalink / raw)
  To: linux-ia64

I'm finding that utime(filename, NULL) doesn't
follow specs - this comes up in plodding through
the LSB certification test suite.

For example, if the process does not own the
file but has write permission, the above
referenced call should succeed but fails with EPERM.

utime() is emulated on Itanium: in the kernel,
fs/open.c doesn't have a sys_utime routine 
if __ia64__ or alpha; the emulation comes from
glibc's sysdeps/unix/utime.c but appears to
be bogus.  The problem is that if the second
argument to utime is NULL the emulation code
does some work to build up a "struct timeval"
array as expected by utimes(), and passes that
off, instead of passing NULL... and so the
proper checks in the NULL case don't get done
by the kernel.

I guess this is a query to see if anyone
on this list knows anything about this code.
Is this just a glibc problem, or should Itanium
go back to providing the non-emulated utime
routine like nearly all the other arch's do
(and so this emulation code is not run).


Mats Wichmann


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-ia64] utime emulation
  2002-08-06 19:01 [Linux-ia64] utime emulation Wichmann, Mats D
@ 2002-08-06 20:23 ` David Mosberger
  2002-08-06 20:40 ` Andreas Schwab
  1 sibling, 0 replies; 3+ messages in thread
From: David Mosberger @ 2002-08-06 20:23 UTC (permalink / raw)
  To: linux-ia64

>>>>> On Tue, 6 Aug 2002 12:01:15 -0700, "Wichmann, Mats D" <mats.d.wichmann@intel.com> said:

  Mats> I'm finding that utime(filename, NULL) doesn't follow specs -
  Mats> this comes up in plodding through the LSB certification test
  Mats> suite.

  Mats> For example, if the process does not own the file but has
  Mats> write permission, the above referenced call should succeed but
  Mats> fails with EPERM.

  Mats> utime() is emulated on Itanium: in the kernel, fs/open.c
  Mats> doesn't have a sys_utime routine if __ia64__ or alpha; the
  Mats> emulation comes from glibc's sysdeps/unix/utime.c but appears
  Mats> to be bogus.  The problem is that if the second argument to
  Mats> utime is NULL the emulation code does some work to build up a
  Mats> "struct timeval" array as expected by utimes(), and passes
  Mats> that off, instead of passing NULL... and so the proper checks
  Mats> in the NULL case don't get done by the kernel.

  Mats> I guess this is a query to see if anyone on this list knows
  Mats> anything about this code.  Is this just a glibc problem, or
  Mats> should Itanium go back to providing the non-emulated utime
  Mats> routine like nearly all the other arch's do (and so this
  Mats> emulation code is not run).

Please report this as a glibc bug.

	--david


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Linux-ia64] utime emulation
  2002-08-06 19:01 [Linux-ia64] utime emulation Wichmann, Mats D
  2002-08-06 20:23 ` David Mosberger
@ 2002-08-06 20:40 ` Andreas Schwab
  1 sibling, 0 replies; 3+ messages in thread
From: Andreas Schwab @ 2002-08-06 20:40 UTC (permalink / raw)
  To: linux-ia64

"Wichmann, Mats D" <mats.d.wichmann@intel.com> writes:

|> I'm finding that utime(filename, NULL) doesn't
|> follow specs - this comes up in plodding through
|> the LSB certification test suite.
|> 
|> For example, if the process does not own the
|> file but has write permission, the above
|> referenced call should succeed but fails with EPERM.
|> 
|> utime() is emulated on Itanium: in the kernel,
|> fs/open.c doesn't have a sys_utime routine 
|> if __ia64__ or alpha; the emulation comes from
|> glibc's sysdeps/unix/utime.c but appears to
|> be bogus.  The problem is that if the second
|> argument to utime is NULL the emulation code
|> does some work to build up a "struct timeval"
|> array as expected by utimes(), and passes that
|> off, instead of passing NULL... and so the
|> proper checks in the NULL case don't get done
|> by the kernel.
|> 
|> I guess this is a query to see if anyone
|> on this list knows anything about this code.
|> Is this just a glibc problem,

Yes.  Here is a patch:

2002-08-06  Andreas Schwab  <schwab@suse.de>

	* sysdeps/unix/utime.c: If TIMES is NULL pass it through to
	utimes.

--- sysdeps/unix/utime.c.~1.3.~	2001-07-16 10:45:00.000000000 +0200
+++ sysdeps/unix/utime.c	2002-08-06 22:29:53.000000000 +0200
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994, 1997, 2002 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -31,7 +31,7 @@ utime (file, times)
      const char *file;
      const struct utimbuf *times;
 {
-  struct timeval timevals[2];
+  struct timeval timevals[2], *tvp;
 
   if (times != NULL)
     {
@@ -39,13 +39,10 @@ utime (file, times)
       timevals[0].tv_usec = 0L;
       timevals[1].tv_sec = (long int) times->modtime;
       timevals[1].tv_usec = 0L;
+      tvp = timevals;
     }
   else
-    {
-      if (__gettimeofday (&timevals[0], NULL) < 0)
-	return -1;
-      timevals[1] = timevals[0];
-    }
+    tvp = NULL;
 
-  return __utimes (file, timevals);
+  return __utimes (file, tvp);
 }

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-06 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-06 19:01 [Linux-ia64] utime emulation Wichmann, Mats D
2002-08-06 20:23 ` David Mosberger
2002-08-06 20:40 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox