netatalk  4.4.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
file.c File Reference
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <utime.h>
#include <atalk/adouble.h>
#include <atalk/afp.h>
#include <atalk/cnid.h>
#include <atalk/dsi.h>
#include <atalk/fce_api.h>
#include <atalk/globals.h>
#include <atalk/logger.h>
#include <atalk/netatalk_conf.h>
#include <atalk/spotlight.h>
#include <atalk/unix.h>
#include <atalk/util.h>
#include <atalk/vfs.h>
#include "desktop.h"
#include "dircache.h"
#include "directory.h"
#include "file.h"
#include "filedir.h"
#include "fork.h"
#include "unix.h"
#include "volume.h"

Data Structures

struct  reenum

Macros

#define PARAM_NEED_ADP(b)
#define APPLETEMP   ".AppleTempXXXXXX"

Functions

static int default_type (void *finder)
void * get_finderinfo (const struct vol *vol, const char *upath, struct adouble *adp, void *data, int islink)
char * set_name (const struct vol *vol, char *data, cnid_t pid, char *name, cnid_t id, uint32_t utf8)
uint32_t get_id (struct vol *vol, struct adouble *adp, const struct stat *st, const cnid_t did, const char *upath, const int len)
 Get CNID for did/upath args both from database and adouble file.
int getmetadata (const AFPObj *obj, struct vol *vol, uint16_t bitmap, struct path *path, struct dir *dir, char *buf, size_t *buflen, struct adouble *adp)
int getfilparams (const AFPObj *obj, struct vol *vol, uint16_t bitmap, struct path *path, struct dir *dir, char *buf, size_t *buflen, int in_enumerate)
int afp_createfile (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
int afp_setfilparams (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
int setfilparams (const AFPObj *obj, struct vol *vol, struct path *path, uint16_t f_bitmap, char *buf)
int renamefile (struct vol *vol, struct dir *ddir, int sdir_fd, char *src, char *dst, char *newname, struct adouble *adp)
 Rename a file, including its resource fork and mac name.
size_t mtoUTF8 (const struct vol *vol, const char *src, size_t srclen, char *dest, size_t destlen)
int copy_path_name (const struct vol *vol, char *newname, char *ibuf)
int afp_copyfile (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
int copyfile (struct vol *s_vol, struct vol *d_vol, struct dir *d_dir, int sfd, char *src, char *dst, char *newname, struct adouble *adp)
static int check_attrib (const struct vol *vol, struct adouble *adp)
int deletefile (const struct vol *vol, int dirfd, char *file, int checkAttrib)
int afp_createid (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static int reenumerate_loop (struct dirent *de, char *mname, void *data)
static int reenumerate_id (struct vol *vol, char *name, struct dir *dir)
int afp_resolveid (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
int afp_deleteid (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
static struct adoublefind_adouble (const AFPObj *obj, struct vol *vol, struct path *path, struct ofork **of, struct adouble *adp)
int afp_exchangefiles (AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)

Variables

const uint8_t ufinderi [ADEDLEN_FINDERI]
static const uint8_t old_ufinderi []
struct path Cur_Path

Macro Definition Documentation

◆ APPLETEMP

#define APPLETEMP   ".AppleTempXXXXXX"

◆ PARAM_NEED_ADP

#define PARAM_NEED_ADP ( b)
Value:
((b) & ((1 << FILPBIT_ATTR) |\
(1 << FILPBIT_CDATE) |\
(1 << FILPBIT_MDATE) |\
(1 << FILPBIT_BDATE) |\
(1 << FILPBIT_FINFO) |\
(1 << FILPBIT_RFLEN) |\
(1 << FILPBIT_EXTRFLEN) |\
(1 << FILPBIT_PDINFO) |\
(1 << FILPBIT_FNUM) |\
(1 << FILPBIT_UNIXPR)))
#define FILPBIT_EXTRFLEN
Definition afpd/file.h:52
#define FILPBIT_FNUM
Definition afpd/file.h:47
#define FILPBIT_RFLEN
Definition afpd/file.h:49
#define FILPBIT_UNIXPR
Definition afpd/file.h:53
#define FILPBIT_MDATE
Definition afpd/file.h:42
#define FILPBIT_CDATE
Definition afpd/file.h:41
#define FILPBIT_ATTR
Definition afpd/file.h:39
#define FILPBIT_FINFO
Definition afpd/file.h:44
#define FILPBIT_BDATE
Definition afpd/file.h:43
#define FILPBIT_PDINFO
Definition afpd/file.h:51

Function Documentation

◆ afp_copyfile()

int afp_copyfile ( AFPObj * obj,
char * ibuf,
size_t ibuflen,
char * rbuf,
size_t * rbuflen )

◆ afp_createfile()

int afp_createfile ( AFPObj * obj,
char * ibuf,
size_t ibuflen,
char * rbuf,
size_t * rbuflen )

◆ afp_createid()

int afp_createid ( AFPObj * obj,
char * ibuf,
size_t ibuflen,
char * rbuf,
size_t * rbuflen )
Returns
a file id

◆ afp_deleteid()

int afp_deleteid ( AFPObj * obj,
char * ibuf,
size_t ibuflen,
char * rbuf,
size_t * rbuflen )

◆ afp_exchangefiles()

int afp_exchangefiles ( AFPObj * obj,
char * ibuf,
size_t ibuflen,
char * rbuf,
size_t * rbuflen )

◆ afp_resolveid()

int afp_resolveid ( AFPObj * obj,
char * ibuf,
size_t ibuflen,
char * rbuf,
size_t * rbuflen )

resolve a file id

◆ afp_setfilparams()

int afp_setfilparams ( AFPObj * obj,
char * ibuf,
size_t ibuflen,
char * rbuf,
size_t * rbuflen )

◆ check_attrib()

int check_attrib ( const struct vol * vol,
struct adouble * adp )
static

◆ copy_path_name()

int copy_path_name ( const struct vol * vol,
char * newname,
char * ibuf )

◆ copyfile()

int copyfile ( struct vol * s_vol,
struct vol * d_vol,
struct dir * d_dir,
int sfd,
char * src,
char * dst,
char * newname,
struct adouble * adp )
Note
if newname is NULL (from directory.c) we don't want to copy the resource fork. because we are doing it elsewhere. currently if newname is NULL then adp is NULL.

◆ default_type()

int default_type ( void * finder)
static

◆ deletefile()

int deletefile ( const struct vol * vol,
int dirfd,
char * file,
int checkAttrib )
Note
dirfd can be used for unlinkat semantics

◆ find_adouble()

struct adouble * find_adouble ( const AFPObj * obj,
struct vol * vol,
struct path * path,
struct ofork ** of,
struct adouble * adp )
static

◆ get_finderinfo()

void * get_finderinfo ( const struct vol * vol,
const char * upath,
struct adouble * adp,
void * data,
int islink )

◆ get_id()

uint32_t get_id ( struct vol * vol,
struct adouble * adp,
const struct stat * st,
const cnid_t did,
const char * upath,
const int len )

Get CNID for did/upath args both from database and adouble file.

  1. Get the objects CNID as stored in its adouble file
  2. Get the objects CNID from the database
  3. Store resource fork data
Parameters
[in,out]volvolume
[in,out]adpadouble struct of object upath, might be NULL
[in]ststat of upath, must NOT be NULL
[in]didparent CNID of upath
[in]upathname of object
[in]lenstrlen of upath

◆ getfilparams()

int getfilparams ( const AFPObj * obj,
struct vol * vol,
uint16_t bitmap,
struct path * path,
struct dir * dir,
char * buf,
size_t * buflen,
int in_enumerate )

◆ getmetadata()

int getmetadata ( const AFPObj * obj,
struct vol * vol,
uint16_t bitmap,
struct path * path,
struct dir * dir,
char * buf,
size_t * buflen,
struct adouble * adp )

◆ mtoUTF8()

size_t mtoUTF8 ( const struct vol * vol,
const char * src,
size_t srclen,
char * dest,
size_t destlen )

convert a Mac long name to an utf8 name

◆ reenumerate_id()

int reenumerate_id ( struct vol * vol,
char * name,
struct dir * dir )
static

◆ reenumerate_loop()

int reenumerate_loop ( struct dirent * de,
char * mname,
void * data )
static

◆ renamefile()

int renamefile ( struct vol * vol,
struct dir * ddir,
int sdir_fd,
char * src,
char * dst,
char * newname,
struct adouble * adp )

Rename a file, including its resource fork and mac name.

renamefile and copyfile take the old and new unix pathnames and the new mac name.

Parameters
volvolume structure
ddirdest dir structure
sdir_fdsource dir fd to which src path is relative (for openat et al semantics) passing -1 means this is not used, src path is a full path
srcthe source path
dstthe dest filename in current dir
newnamethe dest mac name
adpadouble struct of src file, if open, or & zeroed one

◆ set_name()

char * set_name ( const struct vol * vol,
char * data,
cnid_t pid,
char * name,
cnid_t id,
uint32_t utf8 )

◆ setfilparams()

int setfilparams ( const AFPObj * obj,
struct vol * vol,
struct path * path,
uint16_t f_bitmap,
char * buf )

Variable Documentation

◆ Cur_Path

struct path Cur_Path
extern

◆ old_ufinderi

const uint8_t old_ufinderi[]
static
Initial value:
= {
'T', 'E', 'X', 'T', 'U', 'N', 'I', 'X'
}

◆ ufinderi

const uint8_t ufinderi[ADEDLEN_FINDERI]
Initial value:
= {
0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0
}
the format for the finderinfo fields (from IM: Toolbox Essentials):
field bytes subfield bytes
files:
ioFlFndrInfo 16 -> type 4 type field
creator 4 creator field
flags 2 finder flags:
alias, bundle, etc.
location 4 location in window
folder 2 window that contains file
ioFlXFndrInfo 16 -> iconID 2 icon id
unused 6 reserved
script 1 script system
xflags 1 reserved
commentID 2 comment id
putawayID 4 home directory id
static dbd_flags_t flags
Definition cmd_dbd.c:45
static enum op type
Definition nad_cp.c:96
Definition catsearch.c:60