1
0
mirror of git://git.code.sf.net/p/zsh/code synced 2024-09-21 19:31:50 +02:00

26697: test for Linux- and Mac-style xattr functions

This commit is contained in:
Peter Stephenson 2009-03-08 20:20:47 +00:00
parent d968acfacd
commit 6594c0375b
4 changed files with 76 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2009-03-08 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 26697: configure.ac, Src/Modules/attr.c, Src/Modules/attr.mdd:
test for Linux- and Mac- style xattr functions and don't use
if neither appropriate.
2009-03-06 Peter Stephenson <pws@csr.com>
* unposted: fix definition of _perforce_whole_path in 26690.
@ -11346,5 +11352,5 @@
*****************************************************
* This is used by the shell to define $ZSH_PATCHLEVEL
* $Revision: 1.4603 $
* $Revision: 1.4604 $
*****************************************************

View File

@ -42,8 +42,16 @@ bin_getattr(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
unmetafy(*argv, &slen);
unmetafy(*(argv+1), NULL);
if (listxattr(*argv, NULL, 0) > 0) {
if (0 < (len = getxattr(*argv, *(argv+1), value, 255))) {
if (listxattr(*argv, NULL, 0
#ifdef XATTR_EXTRA_ARGS
, 0
#endif
) > 0) {
if (0 < (len = getxattr(*argv, *(argv+1), value, 255
#ifdef XATTR_EXTRA_ARGS
, 0, 0
#endif
))) {
if (len < 256) {
value[len] = '\0';
if (*(argv+2))
@ -67,7 +75,11 @@ bin_setattr(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
unmetafy(*argv, &slen);
unmetafy(*(argv+1), NULL);
unmetafy(*(argv+2), NULL);
if (setxattr(*argv, *(argv+1), *(argv+2), strlen(*(argv+2)), 0)) {
if (setxattr(*argv, *(argv+1), *(argv+2), strlen(*(argv+2)), 0
#ifdef XATTR_EXTRA_ARGS
, 0
#endif
)) {
zwarnnam(nam, "%s: %e", metafy(*argv, slen, META_NOALLOC), errno);
ret = 1;
}
@ -81,7 +93,11 @@ bin_delattr(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
unmetafy(*argv, &slen);
unmetafy(*(argv+1), NULL);
if (removexattr(*argv, *(argv+1))) {
if (removexattr(*argv, *(argv+1)
#ifdef XATTR_EXTRA_ARGS
, 0
#endif
)) {
zwarnnam(nam, "%s: %e", metafy(*argv, slen, META_NOALLOC), errno);
ret = 1;
}
@ -96,7 +112,11 @@ bin_listattr(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
char value[256];
unmetafy(*argv, &slen);
if (0 < (len = listxattr(*argv, value, 256))) {
if (0 < (len = listxattr(*argv, value, 256
#ifdef XATTR_EXTRA_ARGS
, 0
#endif
))) {
if (len < 256) {
char *p = value;
if (*(argv+1))

View File

@ -1,5 +1,5 @@
name=zsh/attr
link='if test "x$ac_cv_func_getxattr" = xyes && test "x$ac_cv_header_sys_xattr_h" = xyes; then
link='if test "x$zsh_cv_use_xattr" = xyes; then
echo dynamic
else
echo no

View File

@ -1251,6 +1251,49 @@ if test x$dynamic = xyes; then
shl_load shl_unload shl_findsym)
fi
AH_TEMPLATE([XATTR_EXTRA_ARGS],
Define if getxattr() etc. require additional MacOS-style arguments)
if test x$ac_cv_func_getxattr = xyes && test x$ac_cv_header_sys_xattr_h = xyes
then
AC_CACHE_CHECK(if getxattr etc. are Linux-like,
zsh_cv_getxattr_linux,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/xattr.h>]],
[[
(void)listxattr("", 0, 0);
(void)getxattr("", "", 0, 0);
(void)setxattr("", "", "", 0, 0);
(void)removexattr("", "");
]])],
[zsh_cv_getxattr_linux=yes],
[zsh_cv_getxattr_linux=no])])
if test x$zsh_cv_getxattr_linux != xyes; then
AC_CACHE_CHECK(if getxattr etc. are MAC-like,
zsh_cv_getxattr_mac,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
#include <sys/xattr.h>]],
[[(void)listxattr("", 0, 0, 0);
(void)getxattr("", "", 0, 0, 0, 0);
(void)setxattr("", "", "", 0, 0, 0);
(void)removexattr("", "", 0);]])],
[zsh_cv_getxattr_mac=yes],
[zsh_cv_getxattr_mac=no])])
if test x$zsh_cv_getxattr_mac = xyes; then
AC_DEFINE(XATTR_EXTRA_ARGS)
fi
fi
fi
AC_CACHE_CHECK(if getxattr etc. are usable,
zsh_cv_use_xattr,
[if test x$zsh_cv_getxattr_linux = xyes || test x$zsh_cv_getxattr_mac = xyes
then
zsh_cv_use_xattr=yes
else
zsh_cv_use_xattr=no
fi])
dnl -------------
dnl CHECK SIGNALS