Re: [1.7] rename/renameat error

2009-09-26 Thread Christopher Faylor
On Fri, Sep 25, 2009 at 06:03:22PM -0600, Eric Blake wrote:
>-BEGIN PGP SIGNED MESSAGE-
>Hash: SHA1
>
>According to Christopher Faylor on 9/25/2009 9:11 AM:
>>> >+  /* POSIX says mkdir("symlink-to-missing/") should create the
>>> >+ directory "missing", but Linux rejects it with EEXIST.  Copy
>>> >+ Linux behavior for now.  */
>>> >+
>>> >+  dlen = strlen (dir);
>>> >+  if (isdirsep (dir[dlen - 1]))
>> 
>> Couldn't this index negatively if dir is zero length?
>
>Yep, and so could rename, where this was copied from.  Fixed in the respin
>below.
>
>> 
>>> >+{
>>> >+  stpcpy (newbuf = tp.c_get (), dir);
>> 
>>Since stpcpy returns a pointer to the end of the buffer couldn't we use
>>that and do pointer arithmetic rather than index arithmetic?
>
>Theoretically, a good compiler can do just as well with either.

But a good compiler is not going to infer that stpcpy is returning
something that you're essentially calculating in the next line.

>But how does it look now?

It looks good.  Thanks.  Please check in.

cgf


fexecve, execvpe

2009-09-26 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

POSIX requires fexecve, and we had all the pieces ready to go.  And to my
surprise, we've had execvpe in the sources for a long time, but just
failed to export it (glibc just added execvpe in 2.10).  OK to apply,
along with the corresponding patch to new-features.sgml and tweaking
unistd.h in newlib?

P.S Any reason that "dtable.h" and "cygheap.h" aren't self-contained?

2009-09-26  Eric Blake  

* exec.cc (fexecve): New function.
* cygwin.din (execvpe, fexecve): Export new fexecve and existing
execvpe.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* posix.sgml: Mention them.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEUEARECAAYFAkq+dvgACgkQ84KuGfSFAYAw3wCePP334FcS28GEkjMge4yz1IOq
4XkAl23iWbcAlOna9F2TmlU65qQ5Zag=
=eR4E
-END PGP SIGNATURE-
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index bee9cd1..a10d18c 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -356,6 +356,7 @@ execve SIGFE
 _execve = execve SIGFE
 execvp SIGFE
 _execvp = execvp SIGFE
+execvpe SIGFE
 exit = cygwin_exit SIGFE
 _exit SIGFE
 exp NOSIGFE
@@ -454,6 +455,7 @@ feof SIGFE
 _feof = feof SIGFE
 ferror SIGFE
 _ferror = ferror SIGFE
+fexecve SIGFE
 fflush SIGFE
 _fflush = fflush SIGFE
 ffs NOSIGFE
diff --git a/winsup/cygwin/exec.cc b/winsup/cygwin/exec.cc
index ee0709c..131439f 100644
--- a/winsup/cygwin/exec.cc
+++ b/winsup/cygwin/exec.cc
@@ -1,6 +1,6 @@
 /* exec.cc: exec system call support.

-   Copyright 1996, 1997, 1998, 2000, 2001, 2002 Red Hat, Inc.
+   Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2009 Red Hat, Inc.

 This file is part of Cygwin.

@@ -14,6 +14,10 @@ details. */
 #include "cygerrno.h"
 #include "path.h"
 #include "environ.h"
+#include "sync.h"
+#include "fhandler.h"
+#include "dtable.h"
+#include "cygheap.h"
 #undef _execve

 /* This is called _execve and not execve because the real execve is defined
@@ -91,3 +95,15 @@ execvpe (const char *path, char * const *argv, char *const 
*envp)
   path_conv buf;
   return  execve (find_exec (path, buf), argv, envp);
 }
+
+extern "C" int
+fexecve (int fd, char * const *argv, char *const *envp)
+{
+  cygheap_fdget cfd (fd);
+  if (cfd < 0)
+{
+  syscall_printf ("-1 = fexecve (%d, %p, %p)", fd, argv, envp);
+  return -1;
+}
+  return execve (cfd->pc.get_win32 (), argv, envp);
+}
diff --git a/winsup/cygwin/include/cygwin/version.h 
b/winsup/cygwin/include/cygwin/version.h
index bd05103..a396b1f 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -367,12 +367,13 @@ details. */
   211: Export fpurge, mkstemps.
   212: Add and export libstdc++ malloc wrappers.
   213: Export canonicalize_file_name, eaccess, euidaccess.
+  214: Export execvpe, fexecve.
  */

  /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */

 #define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 213
+#define CYGWIN_VERSION_API_MINOR 214

  /* There is also a compatibity version number associated with the
shared memory regions.  It is incremented when incompatible
diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml
index 48dce6c..06e49d2 100644
--- a/winsup/cygwin/posix.sgml
+++ b/winsup/cygwin/posix.sgml
@@ -152,6 +152,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).
 fdopendir
 feof
 ferror
+fexecve
 fflush
 ffs
 fgetc
@@ -1015,6 +1016,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).
 envz_remove
 envz_strip
 euidaccess
+execvpe
 exp10
 exp10f
 fcloseall
@@ -1227,7 +1229,6 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008).
 fesetround
 fetestexcept
 feupdateenv
-fexecve
 floorl
 fmal
 fmaxl
-- 
1.6.5.rc1



Re: fexecve, execvpe

2009-09-26 Thread Christopher Faylor
On Sat, Sep 26, 2009 at 02:18:00PM -0600, Eric Blake wrote:
>POSIX requires fexecve, and we had all the pieces ready to go.  And to
>my surprise, we've had execvpe in the sources for a long time, but just
>failed to export it (glibc just added execvpe in 2.10).  OK to apply,
>along with the corresponding patch to new-features.sgml and tweaking
>unistd.h in newlib?

Yes, thanks.

>P.S Any reason that "dtable.h" and "cygheap.h" aren't self-contained?

Since I don't know exactly what you're talking about I'll say "Yes".

cgf


Re: fexecve, execvpe

2009-09-26 Thread Eric Blake
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

According to Christopher Faylor on 9/26/2009 2:37 PM:
> Yes, thanks.

Done.

>> P.S Any reason that "dtable.h" and "cygheap.h" aren't self-contained?
> 
> Since I don't know exactly what you're talking about I'll say "Yes".

When I added just #include "cygheap.h" to exec.cc, I still got compiler
errors.  There were incomplete/undefined types until I also added "sync.h"
and "fhandler.h" prior to "cygheap.h".  I'm just wondering whether
cygheap.h should include these files itself, so that clients don't have to
do it.  But I'm not too worried - there aren't that many clients.

- --
Don't work too hard, make some time for fun as well!

Eric Blake e...@byu.net
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkq+gT8ACgkQ84KuGfSFAYC03gCgrk+53fmwKkX4l5U0Harij92K
CKEAoIwMBsZUhcF34gJzN2a9SvDu35zY
=zObR
-END PGP SIGNATURE-