[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: invalid assumption of m4/getcwd-path-max.m4
From: |
Eric Blake |
Subject: |
Re: invalid assumption of m4/getcwd-path-max.m4 |
Date: |
Mon, 28 Mar 2005 13:08:49 -0700 |
User-agent: |
Mozilla Thunderbird 1.0.2 (Windows/20050317) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Jim Meyering on 3/26/2005 7:17 AM:
> Thanks for reporting that.
> So the test program goes wrong on cygwin because of a
> mkdir failure when the would-be cwd_len exceeds PATH_MAX.
...
> If mkdir fails in a way (what errno value?) that cannot be confused
> with e.g., disk full, then it should be easy to adjust the test program.
> Just test for the combination of a too-large cwd_len and failed mkdir
> with that errno value.
Through cygwin 1.5.13, mkdir was failing with EINVAL, but since that does
not match POSIX, I proposed a patch to cygwin to make it fail with
ENAMETOOLONG in CVS (and the future cygwin 1.5.14). I don't see any
reason to check for EINVAL in this patch, as I already maintain a
cygwin-specific patch to the cygwin distribution of coreutils; but there
might be other systems where ENAMETOOLONG is worth checking, making the
patch below a good idea for coreutils and gnulib.
>
> Can you propose/test a patch?
>
2005-03-28 Eric Blake <address@hidden> (tiny change)
* getcwd-path-max.m4: Return success on systems such as cygwin
where no absolute path name can exceed PATH_MAX.
- --
Life is short - so eat dessert first!
Eric Blake address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFCSGRR84KuGfSFAYARAn2AAJ9QnkfEal0mSBEUW5PYDJ7DbfCyeQCfQkcA
sQTdG9qgpj+rhbQamfoJ7+I=
=ZW6N
-----END PGP SIGNATURE-----
Index: m4/getcwd-path-max.m4
===================================================================
RCS file: /cvsroot/coreutils/coreutils/m4/getcwd-path-max.m4,v
retrieving revision 1.15
diff -u -p -r1.15 getcwd-path-max.m4
--- m4/getcwd-path-max.m4 23 Jan 2005 09:07:57 -0000 1.15
+++ m4/getcwd-path-max.m4 28 Mar 2005 20:05:56 -0000
@@ -98,11 +98,15 @@ main (void)
char *c = NULL;
cwd_len += DIR_NAME_SIZE;
- /* If mkdir or chdir fails, be pessimistic and consider that
- as a failure, too. */
+ /* If mkdir or chdir fails, it could be that this system cannot create
+ any file with an absolute name longer than PATH_MAX, such as cygwin.
+ If so, leave fail as 0, because the current working directory can't
+ be too long for getcwd if it can't even be created. For other
+ errors, be pessimistic and consider that as a failure, too. */
if (mkdir (DIR_NAME, S_IRWXU) < 0 || chdir (DIR_NAME) < 0)
{
- fail = 2;
+ if (! (errno == ERANGE || is_ENAMETOOLONG (errno)))
+ fail = 2;
break;
}