~ubuntu-branches/ubuntu/utopic/xfsprogs/utopic-proposed

« back to all changes in this revision

Viewing changes to include/xfs_dir.h

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2002-04-13 09:45:06 UTC
  • Revision ID: james.westby@ubuntu.com-20020413094506-t8dhemv41gkeg4kx
Tags: 2.0.3-1
New upstream bugfix release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
 
3
 * 
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of version 2 of the GNU General Public License as
 
6
 * published by the Free Software Foundation.
 
7
 * 
 
8
 * This program is distributed in the hope that it would be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
11
 * 
 
12
 * Further, this software is distributed without any warranty that it is
 
13
 * free of the rightful claim of any third person regarding infringement
 
14
 * or the like.  Any license provided herein, whether implied or
 
15
 * otherwise, applies only to this software file.  Patent licenses, if
 
16
 * any, provided herein do not apply to combinations of this program with
 
17
 * other software, or any other product whatsoever.
 
18
 * 
 
19
 * You should have received a copy of the GNU General Public License along
 
20
 * with this program; if not, write the Free Software Foundation, Inc., 59
 
21
 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
 
22
 * 
 
23
 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
 
24
 * Mountain View, CA  94043, or:
 
25
 * 
 
26
 * http://www.sgi.com 
 
27
 * 
 
28
 * For further information regarding this notice, see: 
 
29
 * 
 
30
 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
 
31
 */
 
32
#ifndef __XFS_DIR_H__
 
33
#define __XFS_DIR_H__
 
34
 
 
35
/*
 
36
 * Large directories are structured around Btrees where all the data
 
37
 * elements are in the leaf nodes.  Filenames are hashed into an int,
 
38
 * then that int is used as the index into the Btree.  Since the hashval
 
39
 * of a filename may not be unique, we may have duplicate keys.  The
 
40
 * internal links in the Btree are logical block offsets into the file.
 
41
 *
 
42
 * Small directories use a different format and are packed as tightly
 
43
 * as possible so as to fit into the literal area of the inode.
 
44
 */
 
45
 
 
46
#ifdef XFS_ALL_TRACE
 
47
#define XFS_DIR_TRACE
 
48
#endif
 
49
 
 
50
#if !defined(DEBUG)
 
51
#undef XFS_DIR_TRACE
 
52
#endif
 
53
 
 
54
/*========================================================================
 
55
 * Function prototypes for the kernel.
 
56
 *========================================================================*/
 
57
 
 
58
struct uio;
 
59
struct xfs_bmap_free;
 
60
struct xfs_da_args;
 
61
struct xfs_dinode;
 
62
struct xfs_inode;
 
63
struct xfs_mount;
 
64
struct xfs_trans;
 
65
 
 
66
/*
 
67
 * Directory function types.
 
68
 * Put in structures (xfs_dirops_t) for v1 and v2 directories.
 
69
 */
 
70
typedef void    (*xfs_dir_mount_t)(struct xfs_mount *mp);
 
71
typedef int     (*xfs_dir_isempty_t)(struct xfs_inode *dp);
 
72
typedef int     (*xfs_dir_init_t)(struct xfs_trans *tp,
 
73
                                  struct xfs_inode *dp,
 
74
                                  struct xfs_inode *pdp);
 
75
typedef int     (*xfs_dir_createname_t)(struct xfs_trans *tp,
 
76
                                        struct xfs_inode *dp,
 
77
                                        char *name,
 
78
                                        int namelen,
 
79
                                        xfs_ino_t inum,
 
80
                                        xfs_fsblock_t *first,
 
81
                                        struct xfs_bmap_free *flist,
 
82
                                        xfs_extlen_t total);
 
83
typedef int     (*xfs_dir_lookup_t)(struct xfs_trans *tp,
 
84
                                    struct xfs_inode *dp,
 
85
                                    char *name,
 
86
                                    int namelen,
 
87
                                    xfs_ino_t *inum);
 
88
typedef int     (*xfs_dir_removename_t)(struct xfs_trans *tp,
 
89
                                        struct xfs_inode *dp,
 
90
                                        char *name,
 
91
                                        int namelen,
 
92
                                        xfs_ino_t ino,
 
93
                                        xfs_fsblock_t *first,
 
94
                                        struct xfs_bmap_free *flist,
 
95
                                        xfs_extlen_t total);
 
96
typedef int     (*xfs_dir_getdents_t)(struct xfs_trans *tp,
 
97
                                      struct xfs_inode *dp,
 
98
                                      struct uio *uio,
 
99
                                      int *eofp);
 
100
typedef int     (*xfs_dir_replace_t)(struct xfs_trans *tp,
 
101
                                     struct xfs_inode *dp,
 
102
                                     char *name,
 
103
                                     int namelen,
 
104
                                     xfs_ino_t inum,
 
105
                                     xfs_fsblock_t *first,
 
106
                                     struct xfs_bmap_free *flist,
 
107
                                     xfs_extlen_t total);
 
108
typedef int     (*xfs_dir_canenter_t)(struct xfs_trans *tp,
 
109
                                      struct xfs_inode *dp,
 
110
                                      char *name,
 
111
                                      int namelen);
 
112
typedef int     (*xfs_dir_shortform_validate_ondisk_t)(struct xfs_mount *mp,
 
113
                                                       struct xfs_dinode *dip);
 
114
typedef int     (*xfs_dir_shortform_to_single_t)(struct xfs_da_args *args);
 
115
 
 
116
typedef struct xfs_dirops {
 
117
        xfs_dir_mount_t                         xd_mount;
 
118
        xfs_dir_isempty_t                       xd_isempty;
 
119
        xfs_dir_init_t                          xd_init;
 
120
        xfs_dir_createname_t                    xd_createname;
 
121
        xfs_dir_lookup_t                        xd_lookup;
 
122
        xfs_dir_removename_t                    xd_removename;
 
123
        xfs_dir_getdents_t                      xd_getdents;
 
124
        xfs_dir_replace_t                       xd_replace;
 
125
        xfs_dir_canenter_t                      xd_canenter;
 
126
        xfs_dir_shortform_validate_ondisk_t     xd_shortform_validate_ondisk;
 
127
        xfs_dir_shortform_to_single_t           xd_shortform_to_single;
 
128
} xfs_dirops_t;
 
129
 
 
130
/*
 
131
 * Overall external interface routines.
 
132
 */
 
133
void    xfs_dir_startup(void);  /* called exactly once */
 
134
 
 
135
#define XFS_DIR_MOUNT(mp)       \
 
136
        ((mp)->m_dirops.xd_mount(mp))
 
137
#define XFS_DIR_ISEMPTY(mp,dp)  \
 
138
        ((mp)->m_dirops.xd_isempty(dp))
 
139
#define XFS_DIR_INIT(mp,tp,dp,pdp)      \
 
140
        ((mp)->m_dirops.xd_init(tp,dp,pdp))
 
141
#define XFS_DIR_CREATENAME(mp,tp,dp,name,namelen,inum,first,flist,total) \
 
142
        ((mp)->m_dirops.xd_createname(tp,dp,name,namelen,inum,first,flist,\
 
143
                                      total))
 
144
#define XFS_DIR_LOOKUP(mp,tp,dp,name,namelen,inum)      \
 
145
        ((mp)->m_dirops.xd_lookup(tp,dp,name,namelen,inum))
 
146
#define XFS_DIR_REMOVENAME(mp,tp,dp,name,namelen,ino,first,flist,total) \
 
147
        ((mp)->m_dirops.xd_removename(tp,dp,name,namelen,ino,first,flist,total))
 
148
#define XFS_DIR_GETDENTS(mp,tp,dp,uio,eofp)     \
 
149
        ((mp)->m_dirops.xd_getdents(tp,dp,uio,eofp))
 
150
#define XFS_DIR_REPLACE(mp,tp,dp,name,namelen,inum,first,flist,total)   \
 
151
        ((mp)->m_dirops.xd_replace(tp,dp,name,namelen,inum,first,flist,total))
 
152
#define XFS_DIR_CANENTER(mp,tp,dp,name,namelen) \
 
153
        ((mp)->m_dirops.xd_canenter(tp,dp,name,namelen))
 
154
#define XFS_DIR_SHORTFORM_VALIDATE_ONDISK(mp,dip)       \
 
155
        ((mp)->m_dirops.xd_shortform_validate_ondisk(mp,dip))
 
156
#define XFS_DIR_SHORTFORM_TO_SINGLE(mp,args)    \
 
157
        ((mp)->m_dirops.xd_shortform_to_single(args))
 
158
 
 
159
#define XFS_DIR_IS_V1(mp)       ((mp)->m_dirversion == 1)
 
160
extern xfs_dirops_t xfsv1_dirops;
 
161
 
 
162
#endif  /* __XFS_DIR_H__ */