- /* Check if we need to free (or release) dir structures */
- }
-} /* clearstack() */
-
-/* Fills in dir field of dstack[cidx]. Must fill parent dirs' fields if needed... */
-static int resolve_dir(struct vol *vol, int cidx)
-{
- struct dir *dir, *cdir;
-
- if (dstack[cidx].dir != NULL)
- return 1;
-
- if (dstack[cidx].pidx < 0)
- return 0;
-
- if (dstack[dstack[cidx].pidx].dir == NULL && resolve_dir(vol, dstack[cidx].pidx) == 0)
- return 0;
-
- cdir = dstack[dstack[cidx].pidx].dir;
- dir = cdir->d_child;
- while (dir) {
- if (strcmp(dir->d_m_name, dstack[cidx].m_name) == 0)
- break;
- dir = (dir == cdir->d_child->d_prev) ? NULL : dir->d_next;
- } /* while */
-
- if (!dir) {
- struct path path;
-
- path.u_name = dstack[cidx].path;
- if (of_stat(&path)==-1) {
- LOG(log_debug, logtype_afpd, "resolve_dir: stat %s: %s", dstack[cidx].path, strerror(errno));
- return 0;
- }
- path.m_name = dstack[cidx].m_name;
- path.u_name = dstack[cidx].u_name;
- /* adddir works with a filename not absolute pathname */
- if ((dir = adddir(vol, cdir, &path)) == NULL)
- return 0;