On Fri, 27 Sep 2013 03:50:24 +0200 Roland Mainz wrote:
> Hi!
> ----
> The following code from one of my test scripts no longer work in
> ast-ksh.2013-09-26 on Solaris 11/AMD64/64bit:
> -- snip --
> $ ksh -c 'redirect {n}<. ; redirect {m}</dev/file/flags@xattr@/dev/fd/$n '
> /home/test001/bin/ksh: /dev/file/flags@xattr@/dev/fd/11: cannot open
> [Invalid argument]
> -- snip --
> This fails because of the following code tries to open the parent dir
> of an XATTR dir via:
> -- snip --
> 227 #if O_XATTR
> 228 if ((f = openat(dev.fd, ".",
> O_INTERCEPT|O_RDONLY|O_XATTR)) >= 0)
> 229 {
> 230 fd = openat(f, "..",
> oflags|O_INTERCEPT, mode);
> 231 close(f);
> 232 return fd;
> 233 }
> 234 #endif
> -- snip --
> ... erm.. I don't understand this... what is this code trying to do ?
well someone finally read the code
(which btw has nothing to do with your core dump tickled by a spelling error)
this was a cute discovery
recall the main problem of emulating /dev/fd/<FD> (or /proc/self/fd/<FD>)
is that when its done in the kernel
open("/dev/fd/<FD>",...)
gives you a new file table entry with an independent seek offset and fcntl flags
emulations have had to settle with dup(<FD>) and cross fingers that
the caller would not notice the shared seek offset and fcntl flags
O_XATTR lets us emulate open semantics just like the kernel;
for any file that supports O_XATTR this sequence
xfd = openat(fd, ".", O_XATTR);
ffd = openat(xfd, ...);
close(xfd);
gives an independent descriptor ffd to the same file as descriptor fd
for directories its easier
ffd = openat(fd, ".", ...);
I actually added a comment
/* preserve open() semantics if possible */
its just a bit of a homework assignment to figure out why it does
_______________________________________________
ast-developers mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-developers