341982fbc95441df9a6a19619c0a64666e3ff466
[unfs3] / unfs3 / fh.h
1 /*
2  * UNFS3 low-level filehandle routines
3  * (C) 2004, Pascal Schmidt
4  * see file LICENSE for license details
5  */
6
7 #ifndef UNFS3_FH_H
8 #define UNFS3_FH_H
9
10 #include "backend.h"
11
12 /* minimum length of complete filehandle */
13 #define FH_MINLEN 21
14
15 /* maximum depth of pathname described by filehandle */
16 #define FH_MAXLEN (64 - FH_MINLEN)
17
18 #ifdef __GNUC__
19 typedef struct {
20         uint32                  dev;
21         uint64                  ino;
22         uint32                  gen;
23         uint32                  pwhash;
24         unsigned char   len;
25         unsigned char   inos[FH_MAXLEN];
26 } __attribute__((packed)) unfs3_fh_t;
27 #else
28 #pragma pack(1)
29 typedef struct {
30         uint32                  dev;
31         uint64                  ino;
32         uint32                  gen;
33         uint32                  pwhash;
34         unsigned char   len;
35         unsigned char   inos[FH_MAXLEN];
36 } unfs3_fh_t;
37 #pragma pack(4)
38 #endif
39
40 #define FH_ANY 0
41 #define FH_DIR 1
42
43 #define FD_NONE (-1)                    /* used for get_gen */
44
45 extern int st_cache_valid;              /* stat value is valid */
46 extern backend_statstruct st_cache;     /* cached stat value */
47
48 uint32 get_gen(backend_statstruct obuf, int fd, const char *path);
49
50 int nfh_valid(nfs_fh3 fh);
51 int fh_valid(unfs3_fh_t fh);
52
53 unfs3_fh_t fh_comp_raw(const char *path, struct svc_req *rqstp, int need_dir);
54 u_int fh_length(const unfs3_fh_t *fh);
55
56 unfs3_fh_t *fh_extend(nfs_fh3 fh, uint32 dev, uint64 ino, uint32 gen);
57 post_op_fh3 fh_extend_post(nfs_fh3 fh, uint32 dev, uint64 ino, uint32 gen);
58 post_op_fh3 fh_extend_type(nfs_fh3 fh, const char *path, unsigned int type);
59
60 char *fh_decomp_raw(const unfs3_fh_t *fh);
61
62 #endif