int result;
START_PROFILE(syscall_fchown);
- result = fchown(fsp_get_io_fd(fsp), uid, gid);
+ if (!fsp->fsp_flags.is_pathref) {
+ result = fchown(fsp_get_io_fd(fsp), uid, gid);
+ END_PROFILE(syscall_fchown);
+ return result;
+ }
+
+ if (fsp->fsp_flags.have_proc_fds) {
+ int fd = fsp_get_pathref_fd(fsp);
+ const char *p = NULL;
+ char buf[PATH_MAX];
+
+ p = sys_proc_fd_path(fd, buf, sizeof(buf));
+ if (p != NULL) {
+ result = chown(p, uid, gid);
+ } else {
+ result = -1;
+ }
+ END_PROFILE(syscall_fchown);
+ return result;
+ }
+
+ /*
+ * This is no longer a handle based call.
+ */
+ result = chown(fsp->fsp_name->base_name, uid, gid);
END_PROFILE(syscall_fchown);
return result;
#else