netatalk  4.6.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
fork.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 1990,1993 Regents of The University of Michigan.
3 * All Rights Reserved. See COPYRIGHT.
4 */
5
6#ifndef AFPD_FORK_H
7#define AFPD_FORK_H 1
8
9#include <arpa/inet.h>
10#include <stdio.h>
11
12#include <atalk/adouble.h>
13
14#include "directory.h"
15#include "volume.h"
16
17struct file_key {
18 dev_t dev;
19 ino_t inode;
20};
21
22struct ofork {
23 struct file_key key;
24 struct adouble *of_ad;
25 struct vol *of_vol;
27 uint16_t of_refnum;
29 const unsigned char *of_virtual_data;
31 struct ofork **prevp, *next;
32};
33
34#define OPENFORK_DATA (0)
35#define OPENFORK_RSCS (1<<7)
36
37#define OPENACC_RD (1<<0)
38#define OPENACC_WR (1<<1)
39#define OPENACC_DRD (1<<4)
40#define OPENACC_DWR (1<<5)
41
42/* ofork.of_flags bits */
43#define AFPFORK_DATA (1<<0)
44#define AFPFORK_RSRC (1<<1)
45#define AFPFORK_META (1<<2)
46#define AFPFORK_DIRTY (1<<3)
47#define AFPFORK_ACCRD (1<<4)
48#define AFPFORK_ACCWR (1<<5)
49#define AFPFORK_ACCMASK (AFPFORK_ACCRD | AFPFORK_ACCWR)
50#define AFPFORK_MODIFIED (1<<6)
51#define AFPFORK_ERROR (1<<7)
52#define AFPFORK_VIRTUAL (1<<8)
53
54#define of_name(a) (a)->of_ad->ad_name
55
56/* Check that [offset, offset + length) is contained in a fork without
57 * evaluating the potentially overflowing addition. */
58static inline int fork_range_within(off_t offset, off_t length, off_t size)
59{
60 return offset >= 0 && length >= 0 && size >= 0
61 && offset <= size && length <= size - offset;
62}
63
64/* in ofork.c */
65extern struct ofork *of_alloc(struct vol *, struct dir *,
66 char *, uint16_t *, const int,
67 struct adouble *,
68 struct stat *);
69extern void of_dealloc(struct ofork *);
70extern struct ofork *of_find(const uint16_t);
71extern struct ofork *of_findname(const struct vol *vol, struct path *);
72extern int of_rename(const struct vol *,
73 struct ofork *,
74 struct dir *, const char *,
75 struct dir *, const char *);
76extern int of_flush(const struct vol *);
77extern void of_pforkdesc(FILE *);
78extern void of_log_highwater(void);
79extern int of_stat(const struct vol *vol, struct path *);
80extern int of_statdir(struct vol *vol, struct path *);
81extern int of_closefork(const AFPObj *obj, struct ofork *ofork);
82extern void of_closevol(const AFPObj *obj, const struct vol *vol);
83extern void of_close_all_forks(const AFPObj *obj);
84extern struct adouble *of_ad(const struct vol *, struct path *,
85 struct adouble *);
86extern struct ofork *of_findnameat(int dirfd, struct path *path);
87extern int of_delete_blocked(const struct ofork *of, uint16_t *band,
88 int *content);
89extern void of_close_inode_forks(const AFPObj *obj, const struct vol *vol,
90 struct path *path);
91extern int of_fstatat(int dirfd, struct path *path);
92
94
95extern int of_get_locks(const struct vol *vol, int dirfd, struct path *path,
96 int df_get, off_t df_off, off_t df_len,
97 int rf_get, off_t rf_off, off_t rf_len,
98 uint16_t band_request, int try_root,
99 int *df_locked, int *rf_locked, uint16_t *band_held);
100
101
102/* in fork.c */
103extern int flushfork(struct ofork *);
104extern int fork_setmode_deny(int access, int f_rddny, int f_wrdny,
105 int f_nodny);
106
107/* FP functions */
108int afp_openfork(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
109 size_t *rbuflen);
110int afp_bytelock(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
111 size_t *rbuflen);
112int afp_getforkparams(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
113 size_t *rbuflen);
114int afp_setforkparams(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
115 size_t *rbuflen);
116int afp_read(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
117 size_t *rbuflen);
118int afp_write(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
119 size_t *rbuflen);
120int afp_flushfork(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
121 size_t *rbuflen);
122int afp_flush(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
123 size_t *rbuflen);
124int afp_closefork(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
125 size_t *rbuflen);
126
127int afp_bytelock_ext(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
128 size_t *rbuflen);
129int afp_read_ext(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
130 size_t *rbuflen);
131int afp_write_ext(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
132 size_t *rbuflen);
133int afp_syncfork(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf,
134 size_t *rbuflen);
135#endif
Part of Netatalk's AppleDouble implementatation.
uint32_t cnid_t
Definition adouble.h:157
int afp_closefork(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:1815
int flushfork(struct ofork *ofork)
Definition fork.c:1769
int afp_bytelock(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:1172
int afp_setforkparams(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:879
int afp_flush(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:1687
int afp_flushfork(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:1704
int afp_getforkparams(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:2178
int afp_write_ext(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:2171
int afp_syncfork(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:1738
int afp_read(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:1673
int afp_write(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:2162
int afp_bytelock_ext(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:1179
int fork_setmode_deny(int access, int f_rddny, int f_wrdny, int f_nodny)
Definition fork.c:308
int afp_openfork(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:444
int afp_read_ext(AFPObj *obj, char *ibuf, size_t ibuflen, char *rbuf, size_t *rbuflen)
Definition fork.c:1680
int of_delete_blocked(const struct ofork *of, uint16_t *band, int *content)
Does this child hold a delete-blocking claim on the fork's file?
Definition ofork.c:513
int of_stat(const struct vol *vol, struct path *)
Definition ofork.c:350
int of_flush(const struct vol *)
Definition ofork.c:141
void of_dealloc(struct ofork *)
Definition ofork.c:894
struct ofork * of_findname(const struct vol *vol, struct path *)
Definition ofork.c:431
struct ofork * of_find(const uint16_t)
Definition ofork.c:326
int of_statdir(struct vol *vol, struct path *)
stat the current directory.
Definition ofork.c:383
struct ofork * of_findnameat(int dirfd, struct path *path)
Search for open fork by dirfd/name.
Definition ofork.c:465
static int fork_range_within(off_t offset, off_t length, off_t size)
Definition fork.h:58
void of_pforkdesc(FILE *)
Definition ofork.c:126
void of_closevol(const AFPObj *obj, const struct vol *vol)
Definition ofork.c:1232
struct ofork * of_alloc(struct vol *, struct dir *, char *, uint16_t *, const int, struct adouble *, struct stat *)
Definition ofork.c:200
struct adouble * of_ad(const struct vol *, struct path *, struct adouble *)
Definition ofork.c:1213
int of_rename(const struct vol *, struct ofork *, struct dir *, const char *, struct dir *, const char *)
Definition ofork.c:159
void of_close_inode_forks(const AFPObj *obj, const struct vol *vol, struct path *path)
Close every fork this child holds on path's inode.
Definition ofork.c:570
of_locks_status
Definition fork.h:93
@ OF_LOCKS_OK
Definition fork.h:93
@ OF_LOCKS_NOENT
Definition fork.h:93
@ OF_LOCKS_ERROR
Definition fork.h:93
int of_fstatat(int dirfd, struct path *path)
Definition ofork.c:365
int of_get_locks(const struct vol *vol, int dirfd, struct path *path, int df_get, off_t df_off, off_t df_len, int rf_get, off_t rf_off, off_t rf_len, uint16_t band_request, int try_root, int *df_locked, int *rf_locked, uint16_t *band_held)
Conflict GET (F_GETLK only): read another holder's locks on a file.
Definition ofork.c:650
int of_closefork(const AFPObj *obj, struct ofork *ofork)
Definition ofork.c:942
void of_log_highwater(void)
Definition ofork.c:931
void of_close_all_forks(const AFPObj *obj)
Definition ofork.c:1254
Definition globals.h:190
Definition adouble.h:198
Definition include/atalk/directory.h:72
Definition fork.h:17
dev_t dev
Definition fork.h:18
ino_t inode
Definition fork.h:19
Definition fork.h:22
struct file_key key
Definition fork.h:23
cnid_t of_did
Definition fork.h:26
struct vol * of_vol
Definition fork.h:25
int of_flags
Definition fork.h:28
const unsigned char * of_virtual_data
Definition fork.h:29
struct ofork ** prevp
Definition fork.h:31
struct ofork * next
Definition fork.h:31
uint16_t of_refnum
Definition fork.h:27
struct adouble * of_ad
Definition fork.h:24
off_t of_virtual_len
Definition fork.h:30
Definition include/atalk/directory.h:140
Definition include/atalk/volume.h:33