#include <poll.h>
#include <stdbool.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <bstrlib.h>
#include <netatalk/at.h>
#include <atalk/cnid.h>
#include <atalk/unicode.h>
Go to the source code of this file.
Data Structures | |
struct | asev_data |
struct | asev |
Macros | |
#define | RLIM_MAX 65535 |
#define | EXITERR_CLNT 1 /* client related error */ |
#define | EXITERR_CONF 2 /* error in config files/cmd line parameters */ |
#define | EXITERR_SYS 3 /* local system error */ |
#define | EXITERR_CLOSED 4 /* connection was immediately closed after TCP handshake */ |
#define | AFP_PANIC(why) |
#define | AFP_ASSERT(b) |
#define | MIN(a, b) |
#define | MAX(a, b) |
#define | STRCMP(a, b, c) |
#define | ZERO_STRUCT(a) |
#define | ZERO_STRUCTP(a) |
#define | hton64(x) |
#define | ntoh64(x) |
#define | SAFE_FREE(x) |
#define | diatolower(x) |
#define | diatoupper(x) |
#define | server_unlock(x) |
#define | mod_error() |
#define | strequal(a, b) |
#define | cfrombstr(b) |
#define | BSTRING_STRIP_SLASH(a) |
#define | read_lock(fd, offset, whence, len) |
place read lock on file | |
#define | write_lock(fd, offset, whence, len) |
place write lock on file | |
#define | unlock(fd, offset, whence, len) |
unlock a file |
Enumerations | |
enum | asev_fdtype { IPC_FD , LISTEN_FD } |
Functions | |
char ** | getifacelist (void) |
void | freeifacelist (char **) |
int | atalk_aton (char *, struct at_addr *) |
void | bprint (char *, int) |
int | strdiacasecmp (const char *, const char *) |
int | strndiacasecmp (const char *, const char *, size_t) |
pid_t | server_lock (char *, char *, int) |
int | check_lockfile (const char *program, const char *pidfile) |
int | create_lockfile (const char *program, const char *pidfile) |
void | fault_setup (void(*fn)(void *)) |
void | netatalk_panic (const char *why) |
void * | mod_open (const char *) |
void * | mod_symbol (void *, const char *) |
void | mod_close (void *) |
int | lock_reg (int fd, int cmd, int type, off_t offest, int whence, off_t len) |
lock a file with fctnl | |
int | setnonblock (int fd, int cmd) |
set or unset non-blocking IO on a fd | |
ssize_t | readt (int socket, void *data, const size_t length, int setnonblocking, int timeout) |
ssize_t | writet (int socket, void *data, const size_t length, int setnonblocking, int timeout) |
const char * | getip_string (const struct sockaddr *sa) |
convert an IPv4 or IPv6 address to a static string using inet_ntop | |
unsigned int | getip_port (const struct sockaddr *sa) |
return port number from struct sockaddr | |
void | apply_ip_mask (struct sockaddr *ai, int maskbits) |
apply netmask to IP (v4 or v6) | |
int | compare_ip (const struct sockaddr *sa1, const struct sockaddr *sa2) |
compare IP addresses for equality | |
int | tokenize_ip_port (const char *ipurl, char **address, char **port) |
struct asev * | asev_init (int max) |
bool | asev_add_fd (struct asev *sev, int fd, enum asev_fdtype fdtype, void *private, int protocol) |
bool | asev_del_fd (struct asev *sev, int fd) |
int | send_fd (int socket, int fd) |
int | recv_fd (int fd, int nonblocking) |
const char * | getcwdpath (void) |
get cwd in static buffer | |
const char * | fullpathname (const char *) |
Request absolute path. | |
char * | stripped_slashes_basename (char *p) |
void | randombytes (void *buf, int n) |
int | daemonize (void) |
int | run_cmd (const char *cmd, char **cmd_argv) |
char * | realpath_safe (const char *path) |
const char * | basename_safe (const char *path) |
char * | strtok_quote (char *s, const char *delim) |
const char * | tmpdir (void) |
int | ochdir (const char *dir, int options) |
symlink safe chdir replacement | |
int | ostat (const char *path, struct stat *buf, int options) |
int | ostatat (int dirfd, const char *path, struct stat *st, int options) |
int | ochown (const char *path, uid_t owner, gid_t group, int options) |
int | ochmod (char *path, mode_t mode, const struct stat *st, int options) |
bstring | rel_path_in_vol (const char *path, const char *volpath) |
cnid_t | cnid_for_path (struct _cnid_db *cdb, const char *volpath, const char *path, cnid_t *did) |
void | initline (int, char *) |
int | parseline (int, char *) |
Variables | |
const int | _diacasemap [] |
const int | _dialowermap [] |
Netatalk utility functions
Utility functions for these areas:
#define AFP_ASSERT | ( | b | ) |
#define AFP_PANIC | ( | why | ) |
#define BSTRING_STRIP_SLASH | ( | a | ) |
#define diatolower | ( | x | ) |
#define diatoupper | ( | x | ) |
#define EXITERR_CLNT 1 /* client related error */ |
#define EXITERR_CLOSED 4 /* connection was immediately closed after TCP handshake */ |
#define EXITERR_CONF 2 /* error in config files/cmd line parameters */ |
#define EXITERR_SYS 3 /* local system error */ |
#define hton64 | ( | x | ) |
#define MAX | ( | a, | |
b ) |
#define MIN | ( | a, | |
b ) |
#define mod_error | ( | ) |
#define read_lock | ( | fd, | |
offset, | |||
whence, | |||
len ) |
place read lock on file
fd | (r) File descriptor |
offset | (r) byte offset relative to l_whence |
whence | (r) SEEK_SET, SEEK_CUR, SEEK_END |
len | (r) no. of bytes (0 means to EOF) |
#define RLIM_MAX 65535 |
#define SAFE_FREE | ( | x | ) |
#define server_unlock | ( | x | ) |
#define STRCMP | ( | a, | |
b, | |||
c ) |
#define strequal | ( | a, | |
b ) |
#define unlock | ( | fd, | |
offset, | |||
whence, | |||
len ) |
unlock a file
fd | (r) File descriptor |
offset | (r) byte offset relative to l_whence |
whence | (r) SEEK_SET, SEEK_CUR, SEEK_END |
len | (r) no. of bytes (0 means to EOF) |
#define write_lock | ( | fd, | |
offset, | |||
whence, | |||
len ) |
place write lock on file
fd | (r) File descriptor |
offset | (r) byte offset relative to l_whence |
whence | (r) SEEK_SET, SEEK_CUR, SEEK_END |
len | (r) no. of bytes (0 means to EOF) |
#define ZERO_STRUCT | ( | a | ) |
#define ZERO_STRUCTP | ( | a | ) |
enum asev_fdtype |
|
extern |
apply netmask to IP (v4 or v6)
Modifies IP address in sa->sin[6]_addr-s[6]_addr. The caller is responsible for passing a value for mask that is sensible to the passed address, e.g. 0 <= mask <= 32 for IPv4 or 0<= mask <= 128 for IPv6. mask > 32 for IPv4 is treated as mask = 32, mask > 128 is set to 128 for IPv6.
sa | (rw) pointer to an struct sockaddr |
mask | (r) number of maskbits |
|
extern |
Add a fd to a dynamic pollfd array and associated data array
This uses an additional array of struct polldata which stores type information (enum fdtype) and a pointer to anciliary user data.
|
extern |
Remove fd from asev
|
extern |
Allocate and initialize atalk socket event struct
|
extern |
|
extern |
Returns pointer to static buffer with basename of path
|
extern |
|
extern |
Check lockfile
|
extern |
Resolves CNID of a given path
path might be: (a) relative: "dir/subdir" with cwd: "/afp_volume/topdir" (b) absolute: "/afp_volume/dir/subdir"
path MUST be pointing inside vol, this is usually the case as vol has been build from path using loadvolinfo and friends.
cdb | (r) CNID db handle |
volpath | (r) UNIX path of volume |
path | (r) path, see above |
did | (w) parent CNID of returned CNID |
|
extern |
compare IP addresses for equality
sa1 | (r) pointer to an struct sockaddr |
sa2 | (r) pointer to an struct sockaddr |
|
extern |
Check and create lockfile
|
extern |
Daemonize
Fork, exit parent, setsid(), chdir("/"), close all fds
returns -1 on failure, but you can't do much except exit in that case since we may already have forked
|
extern |
|
extern |
|
extern |
Request absolute path.
|
extern |
get cwd in static buffer
|
extern |
|
extern |
return port number from struct sockaddr
sa | (r) pointer to an struct sockaddr |
|
extern |
convert an IPv4 or IPv6 address to a static string using inet_ntop
IPv6 mapped IPv4 addresses are returned as IPv4 addreses e.g. ::ffff:10.0.0.0 is returned as "10.0.0.0".
sa | (r) pointer to an struct sockaddr |
|
extern |
|
extern |
lock a file with fctnl
This function is called via the macros: read_lock, write_lock, un_lock
fd | (r) File descriptor |
cmd | (r) cmd to fcntl, only F_SETLK is usable here |
type | (r) F_RDLCK, F_WRLCK, F_UNLCK |
offset | (r) byte offset relative to l_whence |
whence | (r) SEEK_SET, SEEK_CUR, SEEK_END |
len | (r) no. of bytes (0 means to EOF) |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
symlink safe chdir replacement
Only chdirs to dir if it doesn't contain symlinks or if symlink checking is disabled
|
extern |
chmod() wrapper for symlink and ACL handling
path | (r) path |
mode | (r) requested mode |
st | (r) stat() of path or NULL |
options | (r) O_NOFOLLOW | O_NETATALK_ACL |
Options description: O_NOFOLLOW: don't chmod() symlinks, do nothing, return 0 O_NETATALK_ACL: call chmod_acl() instead of chmod() O_IGNORE: ignore chmod() request, directly return 0
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
Store n random bytes an buf
|
extern |
non-blocking drop-in replacement for read with timeout using select
socket | (r) socket, if in blocking mode, pass "setnonblocking" arg as 1 |
data | (rw) buffer for the read data |
length | (r) how many bytes to read |
setnonblocking | (r) when non-zero this func will enable and disable non blocking io mode for the socket |
timeout | (r) number of seconds to try reading, 0 means no timeout |
|
extern |
|
extern |
Receive a fd on a suitable socket
fd | (r) PF_UNIX socket to receive on |
nonblocking | (r) 0: fd is in blocking mode - 1: fd is nonblocking, poll for 1 sec |
|
extern |
Build path relativ to volume root
path might be: (a) relative: "dir/subdir" with cwd: "/afp_volume/topdir" (b) absolute: "/afp_volume/dir/subdir"
path | (r) path relative to cwd() or absolute |
volpath | (r) volume path that path is a subdir of (has been computed in volinfo funcs) |
|
extern |
Run command in a child and wait for it to finish
|
extern |
|
extern |
|
extern |
set or unset non-blocking IO on a fd
fd | (r) File descriptor |
cmd | (r) 0: disable non-blocking IO, i.e. block <>0: enable non-blocking IO |
|
extern |
|
extern |
Takes a buffer with a path, strips slashs, returns basename
p | (rw) path path may be "[/][dir/[...]]file" or "[/][dir/[...]]dir/[/]" Result is "file" or "dir" |
|
extern |
|
extern |
extended strtok allows the quoted strings modified strtok.c in glibc 2.0.6
|
extern |
|
extern |
Tokenize IP(4/6) addresses with an optional port into address and port
ipurl | (r) IP URL string |
address | (w) IP address |
port | (w) IP port |
Tokenize IPv4, IPv4:port, IPv6, [IPv6] or [IPv6:port] URL into address and port and return two allocated strings with the address and the port.
If the function returns 0, then address point to a newly allocated valid address string, port may either be NULL or point to a newly allocated port number.
If the function returns -1, then the contents of address and port are undefined.
|
extern |
non-blocking drop-in replacement for read with timeout using select
socket | (r) socket, if in blocking mode, pass "setnonblocking" arg as 1 |
data | (rw) buffer for the read data |
length | (r) how many bytes to read |
setnonblocking | (r) when non-zero this func will enable and disable non blocking io mode for the socket |
timeout | (r) number of seconds to try reading |
|
extern |
const int _dialowermap[] |