netatalk  4.4.0dev
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
main.c File Reference
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/file.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <bstrlib.h>
#include <atalk/cnid_bdb_private.h>
#include <atalk/errchk.h>
#include <atalk/logger.h>
#include <atalk/netatalk_conf.h>
#include <atalk/util.h>
#include "db_param.h"
#include "dbd.h"
#include "dbif.h"
#include "pack.h"
#include "comm.h"

Macros

#define DBOPTIONS   (DB_CREATE | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN)

Functions

static void sig_exit (int signo)
static void block_sigs_onoff (int block)
static int get_lock (int cmd, const char *dbpath)
static int open_db (void)
static int delete_db (void)
static int reinit_db (void)
static int loop (struct db_param *dbp)
static void switch_to_user (char *dir)
static void set_signal (void)
static uid_t uid_from_name (const char *name)
int main (int argc, char *argv[])

Variables

static DBDdbd
static int exit_sig = 0
static int db_locked
static bstring dbpath
static struct db_paramdbp
static struct vol * vol

Macro Definition Documentation

◆ DBOPTIONS

#define DBOPTIONS   (DB_CREATE | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_LOCK | DB_INIT_TXN)

Function Documentation

◆ block_sigs_onoff()

void block_sigs_onoff ( int block)
static

◆ delete_db()

int delete_db ( void )
static

◆ get_lock()

int get_lock ( int cmd,
const char * dbpath )
static

Get lock on db lock file

Parameters
cmd(r) lock command: LOCK_FREE: close lockfd LOCK_UNLOCK: unlock lockm keep lockfd open LOCK_EXCL: F_WRLCK on lockfd LOCK_SHRD: F_RDLCK on lockfd
dbpath(r) path to lockfile, only used on first call, later the stored fd is used
Returns
LOCK_FREE/LOCK_UNLOCK return 0 on success, -1 on error LOCK_EXCL/LOCK_SHRD return LOCK_EXCL or LOCK_SHRD respectively on success, 0 if the lock couldn't be acquired, -1 on other errors

◆ loop()

int loop ( struct db_param * dbp)
static

◆ main()

int main ( int argc ,
char * argv[] )

◆ open_db()

int open_db ( void )
static

◆ reinit_db()

int reinit_db ( void )
static

Close dbd if open, delete it, reopen

Also tries to copy the rootinfo key, that would allow for keeping the db stamp and last used CNID

◆ set_signal()

void set_signal ( void )
static

◆ sig_exit()

void sig_exit ( int signo)
static

◆ switch_to_user()

void switch_to_user ( char * dir)
static

◆ uid_from_name()

uid_t uid_from_name ( const char * name)
static

Variable Documentation

◆ db_locked

int db_locked
static

◆ dbd

DBD* dbd
static

◆ dbp

struct db_param* dbp
static

◆ dbpath

bstring dbpath
static

◆ exit_sig

int exit_sig = 0
static

◆ vol

struct vol* vol
static