DWORD LsaCopyExtendedAttributes(PCSTR pszSrcPath, PCSTR pszDstPath) { DWORD dwError=0; char* list = NULL; ssize_t listLen = _listxattr(pszSrcPath, NULL, 0); list = malloc(listLen); listLen = _listxattr(pszSrcPath, list, listLen); int ns = 0; char* value = NULL; for (ns = 0; ns < listLen; ns += strlen(&list[ns]) + 1) { ssize_t valueLen; valueLen = _getxattr(pszSrcPath, &list[ns], NULL, 0); if (valueLen != -1) { value = malloc(valueLen); _getxattr(pszSrcPath, &list[ns], value, valueLen); dwError = LwMapErrnoToLwError(_setxattr(pszDstPath, &list[ns], value, valueLen)); BAIL_ON_LSA_ERROR(dwError); free(value); value = NULL; } } cleanup: if(list) { free(list); } if(value) { free(value); } return dwError; error: goto cleanup; }
CONFUGA_API int confuga_listxattr(confuga *C, const char *path, char *list, size_t size) { int rc; #if defined(HAS_SYS_XATTR_H) || defined(HAS_ATTR_XATTR_H) SIMPLE_WRAP_UNIX(_listxattr(path, list, size), "listxattr(`%s', %p, %zu)", unresolved_path, list, size); #else return ENOSYS; #endif }
int listxattr(const char *fusepath, char *list, size_t size) { const fuse_context *fc = fuse_get_context(); const Config &config = Config::get(fc); if(fusepath == config.controlfile) return _listxattr_controlfile(list,size); const ugid::SetResetGuard ugid(fc->uid,fc->gid); const rwlock::ReadGuard readlock(&config.srcmountslock); return _listxattr(config.listxattr, config.srcmounts, config.minfreespace, fusepath, list, size); }