#include <arpa/inet.h>#include <dirent.h>#include <sys/sysmacros.h>#include <sys/types.h>#include <atalk/directory.h>#include <atalk/globals.h>#include "volume.h"Go to the source code of this file.
Data Structures | |
| struct | maccess |
Macros | |
| #define | DIRPBIT_ATTR 0 |
| #define | DIRPBIT_PDID 1 |
| #define | DIRPBIT_CDATE 2 |
| #define | DIRPBIT_MDATE 3 |
| #define | DIRPBIT_BDATE 4 |
| #define | DIRPBIT_FINFO 5 |
| #define | DIRPBIT_LNAME 6 |
| #define | DIRPBIT_SNAME 7 |
| #define | DIRPBIT_DID 8 |
| #define | DIRPBIT_OFFCNT 9 |
| #define | DIRPBIT_UID 10 |
| #define | DIRPBIT_GID 11 |
| #define | DIRPBIT_ACCESS 12 |
| #define | DIRPBIT_PDINFO 13 |
| #define | DIRPBIT_UNIXPR 15 |
| #define | FILDIRBIT_ISDIR (1 << 7) |
| #define | FILDIRBIT_ISFILE (0) |
| #define | CNID(a, b) |
| #define | AR_USEARCH (1<<0) |
| #define | AR_UREAD (1<<1) |
| #define | AR_UWRITE (1<<2) |
| #define | AR_UOWN (1<<7) |
Typedefs | |
| typedef int(* | dir_loop) (struct dirent *, char *, void *) |
Functions | |
| void | dir_free_invalid_q (void) |
| Free the queue with invalid struct dirs. | |
| struct dir * | dir_new (const char *mname, const char *uname, const struct vol *, cnid_t pdid, cnid_t did, bstring fullpath, struct stat *) |
| Construct struct dir. | |
| void | dir_free (struct dir *) |
| Free a struct dir and all its members. | |
| struct dir * | dir_add (struct vol *, const struct dir *, struct path *, int) |
| Create struct dir from struct path. | |
| int | dir_modify (const struct vol *vol, struct dir *dir, cnid_t pdid, cnid_t did, const char *new_mname, const char *new_uname, bstring pdir_fullpath) |
| int | dir_remove (const struct vol *vol, struct dir *dir) |
| Remove a file/directory from dircache with automatic curdir recovery. | |
| struct dir * | dirlookup (const struct vol *, cnid_t) |
| Public CNID (Directory ID) resolution (supports files and directories). | |
| struct dir * | dirlookup_strict (const struct vol *, cnid_t) |
| Strict DID resolution with inode validation. | |
| struct dir * | dirlookup_bypath (const struct vol *vol, const char *path) |
| int | movecwd (const struct vol *, struct dir *) |
| chdir() to dir | |
| struct path * | cname (struct vol *, struct dir *, char **) |
| Resolve a catalog node name path. | |
| int | deletecurdir (struct vol *) |
| mode_t | mtoumode (struct maccess *) |
| int | getdirparams (const AFPObj *obj, const struct vol *, uint16_t, struct path *, struct dir *, char *, size_t *) |
| int | setdirparams (struct vol *, struct path *, uint16_t, char *) |
| int | renamedir (struct vol *, int, char *, char *, struct dir *, char *) |
| Rename a directory. | |
| int | path_error (struct path *, int error) |
| void | setdiroffcnt (struct dir *dir, struct stat *st, uint32_t count) |
| int | dirreenumerate (struct dir *dir, struct stat *st) |
| int | for_each_dirent (const struct vol *, char *, dir_loop, void *) |
| int | check_access (const AFPObj *obj, struct vol *, char *name, int mode) |
| int | file_access (const AFPObj *obj, struct vol *vol, struct path *path, int mode) |
| int | netatalk_unlink (const char *name) |
| system unlink with afp error code. | |
| char * | check_dirent (const struct vol *, char *) |
| int | afp_createdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_opendir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_setdirparams (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_closedir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_mapid (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_mapname (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_syncdir (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_enumerate (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_enumerate_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_enumerate_ext2 (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_catsearch (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
| int | afp_catsearch_ext (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen) |
Variables | |
| q_t * | invalid_dircache_entries |
| #define AR_UOWN (1<<7) |
| #define AR_UREAD (1<<1) |
| #define AR_USEARCH (1<<0) |
| #define AR_UWRITE (1<<2) |
| #define CNID | ( | a, | |
| b ) |
| #define DIRPBIT_ACCESS 12 |
| #define DIRPBIT_ATTR 0 |
| #define DIRPBIT_BDATE 4 |
| #define DIRPBIT_CDATE 2 |
| #define DIRPBIT_DID 8 |
| #define DIRPBIT_FINFO 5 |
| #define DIRPBIT_GID 11 |
| #define DIRPBIT_LNAME 6 |
| #define DIRPBIT_MDATE 3 |
| #define DIRPBIT_OFFCNT 9 |
| #define DIRPBIT_PDID 1 |
| #define DIRPBIT_PDINFO 13 |
ProDOS Info
| #define DIRPBIT_SNAME 7 |
| #define DIRPBIT_UID 10 |
| #define DIRPBIT_UNIXPR 15 |
| #define FILDIRBIT_ISDIR (1 << 7) |
is a directory
| #define FILDIRBIT_ISFILE (0) |
is a file
| typedef int(* dir_loop) (struct dirent *, char *, void *) |
| int afp_catsearch | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_catsearch_ext | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_closedir | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_createdir | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_enumerate | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_enumerate_ext | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_enumerate_ext2 | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_mapid | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_mapname | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_opendir | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_setdirparams | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
| int afp_syncdir | ( | AFPObj * | obj, |
| char * | ibuf, | ||
| size_t | ibuflen, | ||
| char * | rbuf, | ||
| size_t * | rbuflen ) |
We can't use unix file's perm to support Apple's inherited protection modes. If we aren't the file's owner we can't change its perms when moving it and smb nfs,... don't even try.
|
extern |
afp_enumerate return an empty listing but offspring count != 0 in afp_getdirparams and the Mac doesn't try to call afp_delete!
Resolve a catalog node name path.
|
extern |
delete an empty directory
|
extern |
Create struct dir from struct path.
Create a new struct dir from struct path. Then add it to the cache.
| [in] | vol | pointer to struct vol, possibly modified in callee |
| [in] | dir | pointer to parent directory |
| [in,out] | path | pointer to struct path with valid path->u_name |
| [in] | len | strlen of path->u_name |
|
extern |
Free a struct dir and all its members.
| dir | (rw) pointer to struct dir |
|
extern |
Free the queue with invalid struct dirs.
|
extern |
|
extern |
Construct struct dir.
Construct struct dir from parameters.
| [in] | m_name | directory name in UTF8-dec |
| [in] | u_name | directory name in server side encoding |
| [in] | vol | pointer to struct vol |
| [in] | pdid | Parent CNID |
| [in] | did | CNID |
| [in] | path | Full unix path to object |
| [in] | st | struct stat of object |
Remove a file/directory from dircache with automatic curdir recovery.
This function centralizes global curdir safety for all callers. When removing a cache entry that is curdir, it attempts curdir recovery via CNID database and falls back to volume root if recovery fails.
| [in] | vol | volume pointer |
| [in,out] | dir | directory/file entry to remove from cache |
Public CNID (Directory ID) resolution (supports files and directories).
Resolves a CNID (Directory ID) to its cached entry. This function supports both files and directories since DID can refer to either type. If cache hit, returns cache entry, if cache miss, returns CNID database record and updates cache
| [in] | vol | pointer to struct vol |
| [in] | did | DID to resolve |
Strict DID resolution with inode validation.
Like dirlookup(), but performs additional validation to ensure the cached directory entry matches the actual filesystem state. This prevents race conditions where a directory has been renamed/moved but the cache entry still points to the old path/has become stale.
Use this for destructive operations (delete, rename, move) where operating on the wrong object could cause data loss.
| [in] | vol | pointer to struct vol |
| [in] | did | DID to resolve |
|
extern |
|
extern |
chdir() to dir
| [in] | vol | pointer to struct vol |
| [in] | dir | pointer to struct dir |
|
extern |
|
extern |
system unlink with afp error code.
|
extern |
|
extern |
Rename a directory.
| vol | volume |
| dirfd | -1 means ignore dirfd (or use AT_FDCWD), otherwise src is relative to dirfd |
| src | old unix filename (not a pathname) |
| dst | new unix filename (not a pathname) |
| newparent | curdir |
| newname | new mac name |
|
extern |
|
extern |