+int of_statdir(struct vol *vol, struct path *path)
+{
+ static char pathname[ MAXPATHLEN + 1] = "../";
+ int ret;
+ size_t len;
+ struct dir *dir;
+
+ if (*path->m_name) {
+ /* not curdir */
+ return of_stat (path);
+ }
+ path->st_errno = 0;
+ path->st_valid = 1;
+ /* FIXME, what about: we don't have r-x perm anymore ? */
+ len = blength(path->d_dir->d_u_name);
+ if (len > (MAXPATHLEN - 3))
+ len = MAXPATHLEN - 3;
+ strncpy(pathname + 3, cfrombstr(path->d_dir->d_u_name), len + 1);
+
+ LOG(log_debug, logtype_afpd, "of_statdir: stating: '%s'", pathname);
+
+ if (!(ret = lstat(pathname, &path->st)))
+ return 0;
+
+ path->st_errno = errno;
+
+ /* hmm, can't stat curdir anymore */
+ if (errno == EACCES && (dir = dirlookup(vol, curdir->d_pdid))) {
+ if (movecwd(vol, dir))
+ return -1;
+ path->st_errno = 0;
+
+ if ((ret = lstat(cfrombstr(path->d_dir->d_u_name), &path->st)) < 0)
+ path->st_errno = errno;
+ }
+
+ return ret;
+}
+
+/* -------------------------- */
+struct ofork *of_findname(struct path *path)
+{
+ struct ofork *of;
+ struct file_key key;
+
+ if (!path->st_valid) {
+ of_stat(path);
+ }
+
+ if (path->st_errno)
+ return NULL;
+
+ key.dev = path->st.st_dev;
+ key.inode = path->st.st_ino;
+
+ for (of = ofork_table[hashfn(&key)]; of; of = of->next) {
+ if (key.dev == of->key.dev && key.inode == of->key.inode ) {
+ return of;
+ }
+ }
+
+ return NULL;
+}
+
+/*!
+ * @brief Search for open fork by dirfd/name
+ *
+ * Function call of_fstatat with dirfd and path and uses dev and ino
+ * to search the open fork table.
+ *
+ * @param dirfd (r) directory fd
+ * @param path (rw) pointer to struct path
+ */
+#ifdef HAVE_RENAMEAT
+struct ofork *of_findnameat(int dirfd, struct path *path)