if (AD_META_OPEN(ad)) {
if (ad->ad_adflags & ADFLAGS_DIR) {
EC_NEG1_LOG( cwd = open(".", O_RDONLY) );
- EC_ZERO_LOG( sys_lsetxattr(".", AD_EA_META, ad->ad_data, AD_DATASZ_EA, 0) );
+ EC_NEG1_LOG( fchdir(ad_data_fileno(ad)) );
+ EC_ZERO_LOG( sys_fsetxattr(".", AD_EA_META, ad->ad_data, AD_DATASZ_EA, 0) );
+ EC_NEG1_LOG( fchdir(cwd) );
+ cwd = -1;
} else {
EC_ZERO_LOG( sys_fsetxattr(ad_data_fileno(ad), AD_EA_META, ad->ad_data, AD_DATASZ_EA, 0) );
}
ad->ad_version = AD_VERSION;
}
-
memset(ad->ad_data, 0, sizeof(ad->ad_data));
if (ad->ad_vers == AD_VERSION2)
}
/* make things invisible */
- if ((ad->ad_options & ADVOL_INVDOTS) && (*path == '.')) {
+ if ((ad->ad_options & ADVOL_INVDOTS)
+ && (*path == '.')
+ && !((adflags & ADFLAGS_DIR) && (path[1] == 0))
+ ) {
ashort = htons(ATTRBIT_INVISIBLE);
ad_setattr(ad, ashort);
ashort = htons(FINDERINFO_INVISIBLE);
if (ad->ad_ops->ad_header_read(path, ad, NULL) != 0) {
LOG(log_error, logtype_default, "ad_open_hf_ea: no EA adouble");
- if (!(adflags & ADFLAGS_CREATE))
+ if (!(adflags & ADFLAGS_CREATE)) {
+ errno = ENOENT;
goto error;
+ }
LOG(log_debug, logtype_default, "ad_open_hf_ea(\"%s\"): creating metadata EA", path);
}
if (dirfd != -1) {
+
if (fchdir(cwdfd) != 0) {
LOG(log_error, logtype_afpd, "ad_openat: cant chdir back, exiting");
exit(EXITERR_SYS);