4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
29 #pragma ident "%Z%%M% %I% %E% SMI"
32 * Support for the fh mapping file for nfslog.
40 * RPC dispatch table for file handles
41 * Indexed by program, version, proc
42 * Based on NFS dispatch table.
43 * Differences: no xdr of args/res.
45 struct nfsl_fh_proc_disp
{
46 void (*nfsl_dis_args
)(); /* dispatch routine for proc */
47 bool_t (*xdr_args
)(); /* XDR function for arguments */
48 bool_t (*xdr_res
)(); /* XDR function for results */
49 int args_size
; /* size of arguments struct */
50 int res_size
; /* size of results struct */
53 struct nfsl_fh_vers_disp
{
54 int nfsl_dis_nprocs
; /* number of procs */
55 struct nfsl_fh_proc_disp
*nfsl_dis_proc_table
; /* proc array */
58 struct nfsl_fh_prog_disp
{
59 int nfsl_dis_prog
; /* program number */
60 int nfsl_dis_versmin
; /* minimum version number */
61 int nfsl_dis_nvers
; /* number of version values */
62 struct nfsl_fh_vers_disp
*nfsl_dis_vers_table
; /* versions array */
65 /* key comprised of inode/gen, currenly 8 or 10 bytes */
66 #define PRIMARY_KEY_LEN_MAX 16
67 typedef char fh_primary_key
[PRIMARY_KEY_LEN_MAX
];
69 /* link key - directory primary key plus name (upto 2 components) */
70 #define SECONDARY_KEY_LEN_MAX (PRIMARY_KEY_LEN_MAX + MAXPATHLEN)
71 typedef char fh_secondary_key
[SECONDARY_KEY_LEN_MAX
];
74 * This is the runtime filehandle table entry. Because an fhandle_t is
75 * used for both Version 2 and Version 3, we don't need two different types
76 * of entries in the table.
78 typedef struct fhlist_ent
{
79 fhandle_t fh
; /* filehandle for this component */
80 time32_t mtime
; /* modification time of entry */
81 time32_t atime
; /* access time of entry */
82 fhandle_t dfh
; /* parent filehandle for this component */
84 short reclen
; /* length of record */
85 char name
[MAXPATHLEN
]; /* variable record */
89 #define EXPORT_POINT 0x01 /* if this is export point */
90 #define NAME_DELETED 0x02 /* is the dir info still valid for this fh? */
91 #define PUBLIC_PATH 0x04 /* is the dir info still valid for this fh? */
94 * Information maintained for the secondary key
95 * Note that this is a variable length record with 4 variable size fields:
96 * fhkey - primary key (must be there)
97 * name - component name (must be there)
98 * next - next link in list (could be null)
99 * prev - previous link in list (could be null)
101 #define MAX_LINK_VARBUF (3 * SECONDARY_KEY_LEN_MAX)
103 typedef struct linkinfo_ent
{
104 fhandle_t dfh
; /* directory filehandle */
105 time32_t mtime
; /* modification time of entry */
106 time32_t atime
; /* access time of entry */
108 short reclen
; /* Actual record length */
109 short fhkey_offset
; /* offset of fhkey, from head of record */
110 short name_offset
; /* offset of name */
111 short next_offset
; /* offset of next link key */
112 short prev_offset
; /* offset of prev link key */
113 char varbuf
[MAX_LINK_VARBUF
]; /* max size for above */
116 /* Macros for lengths of the various fields */
117 #define LN_FHKEY_LEN(link) ((link)->name_offset - (link)->fhkey_offset)
119 #define LN_NAME_LEN(link) ((link)->next_offset - (link)->name_offset)
121 #define LN_NEXT_LEN(link) ((link)->prev_offset - (link)->next_offset)
123 #define LN_PREV_LEN(link) ((link)->reclen - (link)->prev_offset)
125 /* Macros for address of the various fields */
126 #define LN_FHKEY(link) (char *)((uintptr_t)(link) + (link)->fhkey_offset)
128 #define LN_NAME(link) (char *)((uintptr_t)(link) + (link)->name_offset)
130 #define LN_NEXT(link) (char *)((uintptr_t)(link) + (link)->next_offset)
132 #define LN_PREV(link) (char *)((uintptr_t)(link) + (link)->prev_offset)
134 /* Which record can reside in database */
136 fhlist_ent fhlist_rec
;
137 linkinfo_ent link_rec
;
140 void debug_opaque_print(FILE *, void *buf
, int size
);
141 int db_add(char *fhpath
, fhandle_t
*dfh
, char *name
, fhandle_t
*fh
,
143 fhlist_ent
*db_lookup(char *fhpath
, fhandle_t
*fh
, fhlist_ent
*fhrecp
,
145 fhlist_ent
*db_lookup_link(char *fhpath
, fhandle_t
*dfh
, char *name
,
146 fhlist_ent
*fhrecp
, int *errorp
);
147 int db_delete(char *fhpath
, fhandle_t
*fh
);
148 int db_delete_link(char *fhpath
, fhandle_t
*dfh
, char *name
);
149 int db_rename_link(char *fhpath
, fhandle_t
*from_dfh
, char *from_name
,
150 fhandle_t
*to_dfh
, char *to_name
);
151 void db_print_all_keys(char *fhpath
, fsid_t
*fsidp
, FILE *fp
);
153 char *nfslog_get_path(fhandle_t
*fh
, char *name
, char *fhpath
, char *prtstr
);
155 extern fhandle_t public_fh
;
158 * Macro to determine which fhandle to use - input or public fh
160 #define NFSLOG_GET_FHANDLE2(fh) \
161 (((fh)->fh_len > 0) ? fh : &public_fh)
164 * Macro to determine which fhandle to use - input or public fh
166 #define NFSLOG_GET_FHANDLE3(fh3) \
167 (((fh3)->fh3_length == sizeof (fhandle_t)) ? \
168 (fhandle_t *)&(fh3)->fh3_u.data : &public_fh)
174 #endif /* _FHTAB_H */