thanks for the detailed report
the ast::pathdev() function has a few compile-time code paths on
defined(O_XATTR)
the one with defined(O_XATTR)!=0 but fails on a particular fs is the least
exercised
I think this patch will resolve it but I'm not sure about consequences
w.r.t. other callers
unfortunately for the near-term I only have build access to my home suse
machine with defined(O_XATTR)==0
so we'll have to rely on the community to test


On Wed, Nov 6, 2013 at 7:56 AM, Joshuah Hurst <[email protected]> wrote:

> ksh93 does not report the correct kind of error when cd -@ is used for
> a filesystem which doesn't support extended attributes (O_XATTR) like
> /devices on Solaris :
>
> ksh -c 'cd -@ /devices ; :'
> /home/josh/bin/ksh: cd: /dev/file/xattr@/devices//@//: [No such file
> or directory]
>
> It should return the EINVAL from openat(3, ".",
> O_RDONLY|O_NONBLOCK|O_XATTR) from the truss log below:
>
> stat(".", 0xFFFFFD7FFFDFF8C8)                   = 0
> sigaction(SIGCLD, 0xFFFFFD7FFFDFF920, 0xFFFFFD7FFFDFF998) = 0
> lwp_sigmask(SIG_SETMASK, 0x00000000, 0x00000000, 0x00000000,
> 0x00000000) = 0xFFBFFEFF [0xFFFFFFFF]
> openat(10, "/devices", O_RDONLY|O_NONBLOCK)     = 3
> fstat(3, 0xFFFFFD7FFFDFE400)                    = 0
> fcntl(3, F_SETFD, 0x00000001)                   = 0
> openat(3, ".", O_RDONLY|O_NONBLOCK|O_XATTR)     Err#22 EINVAL
> close(3)                                        = 0
> openat(10, "/dev/file/xattr@/devices//@//", O_RDONLY|O_NONBLOCK) Err#2
> ENOENT
> open("/usr/lib/locale/en_US.UTF-8/LC_MESSAGES/SUNW_OST_OSLIB.mo",
> O_RDONLY) Err#2 ENOENT
> /home/josh/bin/ksh: cd: /dev/file/xattr@/devices//@//: [No such file
> or directory]
> write(2, " / h o m e / j o s h / 0 0".., 86)      = 86
> close(10)                                       = 0
> fstat(1, 0xFFFFFD7FFFDFF828)                    = 0
> fstat(2, 0xFFFFFD7FFFDFF828)                    = 0
> _exit(0)
>
> Also why does it do a openat(10, "/dev/file/xattr@/devices//@//",
> O_RDONLY|O_NONBLOCK)?
> That's totally wrong.
>
> Josh
>
> ---------- Forwarded message ----------
> From: Joshuah Hurst <[email protected]>
> Date: Wed, Nov 6, 2013 at 1:16 PM
> Subject: [bug] Problem with cd -@ if filesystem does not support
> extended attributes (O_XATTR)
> To: [email protected], Chester Ramey <[email protected]>
>
>
> Chet, on Solaris the /devices filesystem does not support extended
> attributes (O_XATTR), yet cd -@ returns 0 (success):
>
> ./bash -c 'cd -@ /devices 2>/dev/null; echo $?'
> 0
> ~/bin/ksh -c 'cd -@ /devices 2>/dev/null; echo $?'
> 1
>
> truss shows that bash gets errno==EINVAL but then uses
> chdir("/devices") instead of returning the error:
> stat64("/devices", 0x08047520)                  = 0
> open64("/devices", O_RDONLY|O_NONBLOCK)         = 3
> openat64(3, ".", O_RDONLY|O_XATTR)              Err#22 EINVAL
> close(3)                                        = 0
> chdir("/devices")                               = 0
> brk(0x0819C000)                                 = 0
>
> Josh
>
--- /home/gsf/src/lib/libast/path/pathcanon.c	Fri Sep 27 05:17:46 2013
+++ path/pathcanon.c	Thu Nov  7 00:16:06 2013
@@ -535,9 +535,8 @@
 						r = 0;
 					else if ((n = openat(dev->fd, ".", O_INTERCEPT|O_RDONLY|O_XATTR|O_NONBLOCK)) < 0)
 					{
-						r = 0;
 						close(dev->fd);
-						dev->fd = -1;
+						return 0;
 					}
 					else
 					{
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers

Reply via email to