netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
ea.h File Reference
`#include <atalk/vfs.h>`

Go to the source code of this file.

## Data Structures
struct | ea_entry
struct | ea

## Macros
#define | ENOATTR ENODATA
#define | MAX_EA_SIZE 3802
#define | MAX_REPLY_EXTRA_BYTES 6
#define | ATTRNAMEBUFSIZ 4096
#define | XATTR_CREATE 0x1
#define | XATTR_REPLACE 0x2
#define | AD_EA_META "org.netatalk.Metadata"
#define | AD_EA_META_LEN (sizeof(AD_EA_META) - 1)
#define | AD_EA_RESO "org.netatalk.ResourceFork"
#define | NOT_NETATALK_EA(a)
#define | EA_INITED 0xea494e54
#define | EA_MAGIC 0x61644541
#define | EA_VERSION1 0x01
#define | EA_VERSION EA_VERSION1
#define | EA_MAGIC_OFF 0
#define | EA_MAGIC_LEN 4
#define | EA_VERSION_OFF (EA_MAGIC_OFF + EA_MAGIC_LEN)
#define | EA_VERSION_LEN 2
#define | EA_COUNT_OFF (EA_VERSION_OFF + EA_VERSION_LEN)
#define | EA_COUNT_LEN 2
#define | EA_HEADER_SIZE (EA_MAGIC_LEN + EA_VERSION_LEN + EA_COUNT_LEN)

## Enumerations
enum | { kXAttrNoFollow = 0x1 , kXAttrCreate = 0x2 , kXAttrReplace = 0x4 }
enum | eaflags_t { EA_CREATE = (1 << 1) , EA_RDONLY = (1 << 2) , EA_RDWR = (1 << 3) , EA_DIR = (1 << 4) }

## Functions
ssize_t | sys_getxattr (const char *path, const char *name, void *value, size_t size)
ssize_t | sys_lgetxattr (const char *path, const char *name, void *value, size_t size)
ssize_t | sys_fgetxattr (int filedes, const char *name, void *value, size_t size)
ssize_t | sys_listxattr (const char *path, char *list, size_t size)
ssize_t | sys_llistxattr (const char *path, char *list, size_t size)
ssize_t | sys_flistxattr (int filedes, const char *path, char *list, size_t size)
int | sys_removexattr (const char *path, const char *name)
int | sys_lremovexattr (const char *path, const char *name)
int | sys_fremovexattr (int filedes, const char *path, const char *name)
int | sys_setxattr (const char *path, const char *name, const void *value, size_t size, int flags)
int | sys_lsetxattr (const char *path, const char *name, const void *value, size_t size, int flags)
int | sys_fsetxattr (int filedes, const char *name, const void *value, size_t size, int flags)
int | sys_copyxattr (const char *src, const char *dst)
int | sys_getxattrfd (int fd, const char *uname, int oflag,...)
int | get_easize (const struct vol *vol, char *rbuf, size_t *rbuflen, const char *uname, int oflag, const char *attruname, int fd)
| get size of an EA
int | get_eacontent (const struct vol *vol, char *rbuf, size_t *rbuflen, const char *uname, int oflag, const char *attruname, int maxreply, int fd)
| copy EA into rbuf
int | list_eas (const struct vol *vol, char *attrnamebuf, size_t *buflen, const char *uname, int oflag, int fd)
| copy names of EAs into attrnamebuf
int | set_ea (const struct vol *vol, const char *uname, const char *attruname, const char *ibuf, size_t attrsize, int oflag, int fd)
| set a Solaris native EA
int | remove_ea (const struct vol *vol, const char *uname, const char *attruname, int oflag, int fd)
| remove a EA from a file
int | ea_deletefile (const struct vol *vol, int dirfd, const char *file)
int | ea_renamefile (const struct vol *vol, int dirfd, const char *src, const char *dst)
int | ea_copyfile (const struct vol *vol, int sfd, const char *src, const char *dst)
| copy EAs
int | ea_chown (const struct vol *vol, const char *path, uid_t uid, gid_t gid)
int | ea_chmod_file (const struct vol *vol, const char *name, mode_t mode, struct stat *st)
int | ea_chmod_dir (const struct vol *vol, const char *name, mode_t mode, struct stat *st)
int | sys_get_easize (const struct vol *vol, char *rbuf, size_t *rbuflen, const char *uname, int oflag, const char *attruname, int fd)
| get size of a native EA
int | sys_get_eacontent (const struct vol *vol, char *rbuf, size_t *rbuflen, const char *uname, int oflag, const char *attruname, int maxreply, int fd)
| copy native EA into rbuf
int | sys_list_eas (const struct vol *vol, char *attrnamebuf, size_t *buflen, const char *uname, int oflag, int fd)
| copy names of native EAs into attrnamebuf
int | sys_set_ea (const struct vol *vol, const char *uname, const char *attruname, const char *ibuf, size_t attrsize, int oflag, int fd)
| set a native EA
int | sys_remove_ea (const struct vol *vol, const char *uname, const char *attruname, int oflag, int fd)
| remove a native EA
int | sys_ea_copyfile (const struct vol *vol, int sfd, const char *src, const char *dst)
| copy EAs
int | ea_open (const struct vol *vol, const char *uname, eaflags_t eaflags, struct ea *ea)
| open EA header file, create if it doesnt exits and called with O_CREATE
int | ea_openat (const struct vol *vol, int dirfd, const char *uname, eaflags_t eaflags, struct ea *ea)
| openat like wrapper for ea_open, takes a additional file descriptor
int | ea_close (struct ea *ea)
| flushes and closes an ea handle
char * | ea_path (const struct ea *ea, const char *eaname, int macname)
| return name of ea header filename

## Macro Definition Documentation

## ◆ AD_EA_META

#define AD_EA_META "org.netatalk.Metadata"

## ◆ AD_EA_META_LEN

#define AD_EA_META_LEN (sizeof(AD_EA_META) - 1)

## ◆ AD_EA_RESO

#define AD_EA_RESO "org.netatalk.ResourceFork"

## ◆ ATTRNAMEBUFSIZ

#define ATTRNAMEBUFSIZ 4096

Library user must provide a static buffer of size ATTRNAMEBUFSIZ. It's used when listing EAs as intermediate buffer. For afpd it's defined in extattrs.c.

## ◆ EA_COUNT_LEN

#define EA_COUNT_LEN 2

## ◆ EA_COUNT_OFF

#define EA_COUNT_OFF (EA_VERSION_OFF + EA_VERSION_LEN)

## ◆ EA_HEADER_SIZE

#define EA_HEADER_SIZE (EA_MAGIC_LEN + EA_VERSION_LEN + EA_COUNT_LEN)

## ◆ EA_INITED

#define EA_INITED 0xea494e54

ea"INT", for interfacing ea_open w. ea_close

## ◆ EA_MAGIC

#define EA_MAGIC 0x61644541

"adEA"

## ◆ EA_MAGIC_LEN

#define EA_MAGIC_LEN 4

## ◆ EA_MAGIC_OFF

#define EA_MAGIC_OFF 0

## ◆ EA_VERSION

#define EA_VERSION EA_VERSION1

## ◆ EA_VERSION1

#define EA_VERSION1 0x01

## ◆ EA_VERSION_LEN

#define EA_VERSION_LEN 2

## ◆ EA_VERSION_OFF

#define EA_VERSION_OFF (EA_MAGIC_OFF + EA_MAGIC_LEN)

## ◆ ENOATTR

#define ENOATTR ENODATA

## ◆ MAX_EA_SIZE

#define MAX_EA_SIZE 3802

This seems to be the current limit fo HFS+, we arbitrarily force that which also safes us from buffer overflows

## ◆ MAX_REPLY_EXTRA_BYTES

#define MAX_REPLY_EXTRA_BYTES 6

req_count has space for AFP response bitmap and length as well, so 6 bytes

## ◆ NOT_NETATALK_EA

#define NOT_NETATALK_EA | ( |  | a | ) |

Value:
(strcmp((a), AD_EA_META) != 0) && (strcmp((a), AD_EA_RESO) != 0)
AD_EA_META
#define AD_EA_META
Definition ea.h:82
AD_EA_RESO
#define AD_EA_RESO
Definition ea.h:89

## ◆ XATTR_CREATE

#define XATTR_CREATE 0x1

set value, fail if attr already exists

## ◆ XATTR_REPLACE

#define XATTR_REPLACE 0x2

set value, fail if attr does not exist

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
kXAttrNoFollow |
kXAttrCreate |
kXAttrReplace |

## ◆ eaflags_t

enum eaflags_t

Enumerator
EA_CREATE | create if not existing on ea_open
EA_RDONLY | open read only
EA_RDWR | open read/write
EA_DIR | ea header file is for a dir, ea_open adds it as appropriate

## Function Documentation

## ◆ ea_chmod_dir()

int ea_chmod_dir | ( | const struct vol * | vol,
|  | const char * | name,
|  | mode_t | mode,
|  | struct stat * | st )
| extern

## ◆ ea_chmod_file()

int ea_chmod_file | ( | const struct vol * | vol,
|  | const char * | name,
|  | mode_t | mode,
|  | struct stat * | st )
| extern

## ◆ ea_chown()

int ea_chown | ( | const struct vol * | vol,
|  | const char * | path,
|  | uid_t | uid,
|  | gid_t | gid )
| extern

## ◆ ea_close()

int ea_close | ( | struct ea * | ea | ) |
| extern

flushes and closes an ea handle

Parameters

  [in,out] | ea | pointer to ea handle

Returns
  0 on success, -1 on error

Note
  Flushes and then closes and frees all resouces held by ea handle. Pack data in ea into ea_data, then write ea_data to disk

## ◆ ea_copyfile()

int ea_copyfile | ( | const struct vol * | vol,
|  | int | sfd,
|  | const char * | src,
|  | const char * | dst )
| extern

copy EAs

Parameters

  [in] | vol | current volume
  [in] | sfd | source file descriptor
  [in] | src | source path
  [in] | dst | destination path

Returns
  AFP code AFP_OK on success or appropriate AFP error code

Note
  Copies EAs from source file to dest file.

## ◆ ea_deletefile()

int ea_deletefile | ( | const struct vol * | vol,
|  | int | dirfd,
|  | const char * | file )
| extern

## ◆ ea_open()

int ea_open | ( | const struct vol * | vol,
|  | const char * | uname,
|  | eaflags_t | eaflags,
|  | struct ea * | ea )
| extern

open EA header file, create if it doesnt exits and called with O_CREATE

Parameters

  [in] | vol | current volume
  [in] | uname | filename for which we have to open a header
  [in] | eaflags | flag to control open behavior: EA_CREATE: create if it doesn't exist (without it won't be created) EA_RDONLY: open read only EA_RDWR: open read/write Either EA_RDONLY or EA_RDWR MUST be requested
  [out] | ea | pointer to a struct ea that we fill

Returns
  0 on success, -1 on misc error with errno = EFAULT, -2 if no EA header exists with errno = ENOENT

Note
  opens header file and stores fd in ea->ea_fd. Size of file is put into ea->ea_size. number of EAs is stored in ea->ea_count. flags are remembered in ea->ea_flags. file is either read or write locked depending on the open flags. When you're done with struct ea you must call ea_close on it.

## ◆ ea_openat()

int ea_openat | ( | const struct vol * | vol,
|  | int | dirfd,
|  | const char * | uname,
|  | eaflags_t | eaflags,
|  | struct ea * | ea )
| extern

openat like wrapper for ea_open, takes a additional file descriptor

Parameters

  [in] | vol | current volume
  [in] | dirfd | openat like file descriptor
  [in] | uname | filename for which we have to open a header
  [in] | eaflags | flag to control open behavior: EA_CREATE: create if it doesn't exist (without it won't be created) EA_RDONLY: open read only EA_RDWR: open read/write Either EA_RDONLY or EA_RDWR MUST be requested
  [out] | ea | pointer to a struct ea that we fill

Returns
  0 on success, -1 on misc error with errno = EFAULT, -2 if no EA header exists with errno = ENOENT

Note
  opens header file and stores fd in ea->ea_fd. Size of file is put into ea->ea_size. number of EAs is stored in ea->ea_count. flags are remembered in ea->ea_flags. file is either read or write locked depending on the open flags. When you're done with struct ea you must call ea_close on it.

## ◆ ea_path()

char * ea_path | ( | const struct ea * | ea,
|  | const char * | eaname,
|  | int | macname )
| extern

return name of ea header filename

Parameters

  [in] | ea | ea handle
  [in] | eaname | name of EA or NULL
  [in] | macname | if != 0 call mtoupath on eaname

Returns
  pointer to name in static buffer, NULL on error

Note
  - Calls ad_open, copies buffer, appends "::EA" and if supplied append eanme
  - Files: "file" -> "file/.AppleDouble/file::EA"
  - Dirs: "dir" -> "dir/.AppleDouble/.Parent::EA"
  - "file" with EA "myEA" -> "file/.AppleDouble/file::EA:myEA"

## ◆ ea_renamefile()

int ea_renamefile | ( | const struct vol * | vol,
|  | int | dirfd,
|  | const char * | src,
|  | const char * | dst )
| extern

## ◆ get_eacontent()

int get_eacontent | ( | const struct vol * | vol,
|  | char * | rbuf,
|  | size_t * | rbuflen,
|  | const char * | uname,
|  | int | oflag,
|  | const char * | attruname,
|  | int | maxreply,
|  | int | fd )
| extern

copy EA into rbuf

Parameters

  [in] | vol | current volume
  [out] | rbuf | DSI reply buffer
  [in,out] | rbuflen | current length of data in reply buffer
  [in] | uname | filename
  [in] | oflag | link and create flag
  [in] | attruname | name of attribute
  [in] | maxreply | maximum EA size as of current specs/real-life
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Copies EA into rbuf. Increments *rbuflen accordingly.

## ◆ get_easize()

int get_easize | ( | const struct vol * | vol,
|  | char * | rbuf,
|  | size_t * | rbuflen,
|  | const char * | uname,
|  | int | oflag,
|  | const char * | attruname,
|  | int | fd )
| extern

get size of an EA

Parameters

  [in] | vol | current volume
  [out] | rbuf | DSI reply buffer
  [in,out] | rbuflen | current length of data in reply buffer
  [in] | uname | filename
  [in] | oflag | link and create flag
  [in] | attruname | name of attribute
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Copies EA size into rbuf in network order. Increments *rbuflen +4.

## ◆ list_eas()

int list_eas | ( | const struct vol * | vol,
|  | char * | attrnamebuf,
|  | size_t * | buflen,
|  | const char * | uname,
|  | int | oflag,
|  | int | fd )
| extern

copy names of EAs into attrnamebuf

Parameters

  [in] | vol | current volume
  [out] | attrnamebuf | store names a consecutive C strings here
  [in,out] | buflen | length of names in attrnamebuf
  [in] | uname | filename
  [in] | oflag | link and create flag
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Copies names of all EAs of uname as consecutive C strings into rbuf. Increments *buflen accordingly.

## ◆ remove_ea()

int remove_ea | ( | const struct vol * | vol,
|  | const char * | uname,
|  | const char * | attruname,
|  | int | oflag,
|  | int | fd )
| extern

remove a EA from a file

Parameters

  [in] | vol | current volume
  [in] | uname | filename
  [in] | attruname | EA name
  [in] | oflag | link and create flag
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Removes EA attruname from file uname.

## ◆ set_ea()

int set_ea | ( | const struct vol * | vol,
|  | const char * | uname,
|  | const char * | attruname,
|  | const char * | ibuf,
|  | size_t | attrsize,
|  | int | oflag,
|  | int | fd )
| extern

set a Solaris native EA

Parameters

  [in] | vol | current volume
  [in] | uname | filename
  [in] | attruname | EA name
  [in] | ibuf | buffer with EA content
  [in] | attrsize | length EA in ibuf
  [in] | oflag | link and create flag
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Copies names of all EAs of uname as consecutive C strings into rbuf. Increments *rbuflen accordingly.

## ◆ sys_copyxattr()

int sys_copyxattr | ( | const char * | src,
|  | const char * | dst )

## ◆ sys_ea_copyfile()

int sys_ea_copyfile | ( | const struct vol * | vol,
|  | int | sfd,
|  | const char * | src,
|  | const char * | dst )
| extern

copy EAs

Parameters

  [in] | vol | current volume
  [in] | sfd | source file descriptor
  [in] | src | source path
  [in] | dst | destination path

Returns
  AFP code AFP_OK on success or appropriate AFP error code

Note
  Copies EAs from source file to dest file.

## ◆ sys_fgetxattr()

ssize_t sys_fgetxattr | ( | int | filedes,
|  | const char * | name,
|  | void * | value,
|  | size_t | size )

## ◆ sys_flistxattr()

ssize_t sys_flistxattr | ( | int | filedes,
|  | const char * | path,
|  | char * | list,
|  | size_t | size )

## ◆ sys_fremovexattr()

int sys_fremovexattr | ( | int | filedes,
|  | const char * | path,
|  | const char * | name )

## ◆ sys_fsetxattr()

int sys_fsetxattr | ( | int | filedes,
|  | const char * | name,
|  | const void * | value,
|  | size_t | size,
|  | int | flags )

## ◆ sys_get_eacontent()

int sys_get_eacontent | ( | const struct vol * | vol,
|  | char * | rbuf,
|  | size_t * | rbuflen,
|  | const char * | uname,
|  | int | oflag,
|  | const char * | attruname,
|  | int | maxreply,
|  | int | fd )
| extern

copy native EA into rbuf

Parameters

  [in] | vol | current volume
  [out] | rbuf | DSI reply buffer
  [in,out] | rbuflen | current length of data in reply buffer
  [in] | uname | filename
  [in] | oflag | link and create flag
  [in] | attruname | name of attribute
  [in] | maxreply | maximum EA size as of current specs/real-life
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Copies EA into rbuf. Increments *rbuflen accordingly.

## ◆ sys_get_easize()

int sys_get_easize | ( | const struct vol * | vol,
|  | char * | rbuf,
|  | size_t * | rbuflen,
|  | const char * | uname,
|  | int | oflag,
|  | const char * | attruname,
|  | int | fd )
| extern

get size of a native EA

Parameters

  [in] | vol | current volume
  [out] | rbuf | DSI reply buffer
  [in,out] | rbuflen | current length of data in reply buffer
  [in] | uname | filename
  [in] | oflag | link and create flag
  [in] | attruname | name of attribute
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Copies EA size into rbuf in network order. Increments *rbuflen +4.

## ◆ sys_getxattr()

ssize_t sys_getxattr | ( | const char * | path,
|  | const char * | name,
|  | void * | value,
|  | size_t | size )

## ◆ sys_getxattrfd()

int sys_getxattrfd | ( | int | fd,
|  | const char * | uname,
|  | int | oflag,
|  |  | ... )

## ◆ sys_lgetxattr()

ssize_t sys_lgetxattr | ( | const char * | path,
|  | const char * | name,
|  | void * | value,
|  | size_t | size )

## ◆ sys_list_eas()

int sys_list_eas | ( | const struct vol * | vol,
|  | char * | attrnamebuf,
|  | size_t * | buflen,
|  | const char * | uname,
|  | int | oflag,
|  | int | fd )
| extern

copy names of native EAs into attrnamebuf

Parameters

  [in] | vol | current volume
  [out] | attrnamebuf | store names a consecutive C strings here
  [in,out] | buflen | length of names in attrnamebuf
  [in] | uname | filename
  [in] | oflag | link and create flag
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Copies names of all EAs of uname as consecutive C strings into rbuf. Increments *rbuflen accordingly. We hide the adouble:ea extended attributes here, we do not allow reading, writing and deleting them.

## ◆ sys_listxattr()

ssize_t sys_listxattr | ( | const char * | path,
|  | char * | list,
|  | size_t | size )

## ◆ sys_llistxattr()

ssize_t sys_llistxattr | ( | const char * | path,
|  | char * | list,
|  | size_t | size )

## ◆ sys_lremovexattr()

int sys_lremovexattr | ( | const char * | path,
|  | const char * | name )

## ◆ sys_lsetxattr()

int sys_lsetxattr | ( | const char * | path,
|  | const char * | name,
|  | const void * | value,
|  | size_t | size,
|  | int | flags )

## ◆ sys_remove_ea()

int sys_remove_ea | ( | const struct vol * | vol,
|  | const char * | uname,
|  | const char * | attruname,
|  | int | oflag,
|  | int | fd )
| extern

remove a native EA

Parameters

  [in] | vol | current volume
  [in] | uname | filename
  [in] | attruname | EA name
  [in] | oflag | link and create flag
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

Note
  Removes EA attruname from file uname.

## ◆ sys_removexattr()

int sys_removexattr | ( | const char * | path,
|  | const char * | name )

## ◆ sys_set_ea()

int sys_set_ea | ( | const struct vol * | vol,
|  | const char * | uname,
|  | const char * | attruname,
|  | const char * | ibuf,
|  | size_t | attrsize,
|  | int | oflag,
|  | int | fd )
| extern

set a native EA

Parameters

  [in] | vol | current volume
  [in] | uname | filename
  [in] | attruname | EA name
  [in] | ibuf | buffer with EA content
  [in] | attrsize | length EA in ibuf
  [in] | oflag | link and create flag
  [in] | fd | file descriptor

Returns
  AFP code: AFP_OK on success or appropriate AFP error code

## ◆ sys_setxattr()

int sys_setxattr | ( | const char * | path,
|  | const char * | name,
|  | const void * | value,
|  | size_t | size,
|  | int | flags )