Discussion:
[ast-developers] Patch for /dev/file/xattr:/dev/fd/$d/myxattr ... /
Roland Mainz
2013-08-30 22:07:39 UTC
Permalink
ksh -c 'mkdir -p foo2 ; redirect {d}<foo2/ ; redirect
foo2 ; ls ; cat myxattr' myxattr SUNWattr_ro SUNWattr_rw
bla
Do you have a patch for that? It sounds you found a middle way which
might satisfy Glenn's love for /dev/file and marry it with a sane
approach to access files in xattr directories.
Attached (as "astksh20130829_dev_file_xattr001.diff.txt") is a patch
which allows /dev/file/xattr/<PATH> to open files with |O_XATTR| (see
Olga's example usage above, e.g. first you need a file descriptor
which references the file/directory for which you wish to access XATTR
data and then use /dev/file/xattr:/dev/fd/$d/<name> to access
attribute <name>) and adds some other missing flags like |O_NOLINKS|,
|O_NOFOLLOW|, |O_RSYNC|, |O_DSYNC| and removed the duplicate |O_ASYNC|
entry...

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
-------------- next part --------------
diff -r -u build_i386_64bit_debug/src/lib/libast/path/pathcanon.c build_i386_64bit_debug_file_xattr/src/lib/libast/path/pathcanon.c
--- src/lib/libast/path/pathcanon.c 2013-08-29 08:37:08.000000000 +0200
+++ src/lib/libast/path/pathcanon.c 2013-08-30 22:47:15.780363633 +0200
@@ -275,11 +275,51 @@
return 0;
#endif
}
- else if (s[0] == 's' && s[1] == 'y' && s[2] == 'n' && s[3] == 'c' && (s[4] == ',' || s[4] == ':'))
+ else if (s[0] == 'd' && s[1] == 's' && s[2] == 'y' && s[3] == 'n' && s[4] == 'c' && (s[5] == ',' || s[5] == ':'))
{
-#ifdef O_ASYNC
- s += 4;
- dev->oflags |= O_ASYNC;
+#ifdef O_DSYNC
+ s += 5;
+ dev->oflags |= O_DSYNC;
+#else
+ errno = ENXIO;
+ return 0;
+#endif
+ }
+ else if (s[0] == 'r' && s[1] == 's' && s[2] == 'y' && s[3] == 'n' && s[4] == 'c' && (s[5] == ',' || s[5] == ':'))
+ {
+#ifdef O_RSYNC
+ s += 5;
+ dev->oflags |= O_RSYNC;
+#else
+ errno = ENXIO;
+ return 0;
+#endif
+ }
+ else if (s[0] == 'x' && s[1] == 'a' && s[2] == 't' && s[3] == 't' && s[4] == 'r' && (s[5] == ',' || s[5] == ':'))
+ {
+#ifdef O_XATTR
+ s += 5;
+ dev->oflags |= O_XATTR;
+#else
+ errno = ENXIO;
+ return 0;
+#endif
+ }
+ else if (s[0] == 'n' && s[1] == 'o' && s[2] == 'f' && s[3] == 'o' && s[4] == 'l' && s[5] == 'l' && s[6] == 'o' && s[7] == 'w' && (s[8] == ',' || s[8] == ':'))
+ {
+#ifdef O_NOFOLLOW
+ s += 8;
+ dev->oflags |= O_NOFOLLOW;
+#else
+ errno = ENXIO;
+ return 0;
+#endif
+ }
+ else if (s[0] == 'n' && s[1] == 'o' && s[2] == 'l' && s[3] == 'i' && s[4] == 'n' && s[5] == 'k' && s[6] == 's' && (s[7] == ',' || s[7] == ':'))
+ {
+#ifdef O_NOLINKS
+ s += 7;
+ dev->oflags |= O_NOLINKS;
#else
errno = ENXIO;
return 0;
diff -r -u build_i386_64bit_debug/src/lib/libast/path/pathopen.c build_i386_64bit_debug_file_xattr/src/lib/libast/path/pathopen.c
--- src/lib/libast/path/pathopen.c 2013-08-29 07:17:52.000000000 +0200
+++ src/lib/libast/path/pathopen.c 2013-08-30 14:05:06.109801440 +0200
@@ -224,7 +224,7 @@

if (oflags & (O_DIRECTORY|O_SEARCH))
return openat(dev.fd, ".", oflags|O_INTERCEPT, mode);
-#if O_XATTR
+#if disabled_O_XATTR
if ((f = openat(dev.fd, ".", O_INTERCEPT|O_RDONLY|O_XATTR)) >= 0)
{
fd = openat(f, "..", oflags|O_INTERCEPT, mode);
Loading...