~ubuntu-branches/ubuntu/edgy/xfsprogs/edgy

« back to all changes in this revision

Viewing changes to libxfs/xfs_dir2.c

  • Committer: Bazaar Package Importer
  • Author(s): Nathan Scott
  • Date: 2004-07-28 21:11:38 UTC
  • Revision ID: james.westby@ubuntu.com-20040728211138-0v4pdnunnp7na5lm
Tags: 2.6.20-1
* New upstream release.
* Fix xfs_io segfault on non-XFS files.  (closes: #260470)
* Fix packaging botch, deleted files included.  (closes: #260491)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2000 Silicon Graphics, Inc.  All Rights Reserved.
3
 
 * 
 
2
 * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
 
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify it
5
5
 * under the terms of version 2 of the GNU General Public License as
6
6
 * published by the Free Software Foundation.
7
 
 * 
 
7
 *
8
8
 * This program is distributed in the hope that it would be useful, but
9
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 
 * 
 
11
 *
12
12
 * Further, this software is distributed without any warranty that it is
13
13
 * free of the rightful claim of any third person regarding infringement
14
14
 * or the like.  Any license provided herein, whether implied or
15
15
 * otherwise, applies only to this software file.  Patent licenses, if
16
16
 * any, provided herein do not apply to combinations of this program with
17
17
 * other software, or any other product whatsoever.
18
 
 * 
 
18
 *
19
19
 * You should have received a copy of the GNU General Public License along
20
20
 * with this program; if not, write the Free Software Foundation, Inc., 59
21
21
 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
22
 
 * 
 
22
 *
23
23
 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24
24
 * Mountain View, CA  94043, or:
25
 
 * 
26
 
 * http://www.sgi.com 
27
 
 * 
28
 
 * For further information regarding this notice, see: 
29
 
 * 
 
25
 *
 
26
 * http://www.sgi.com
 
27
 *
 
28
 * For further information regarding this notice, see:
 
29
 *
30
30
 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
31
31
 */
32
32
 
53
53
        mp->m_dirdatablk = XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_DATA_FIRSTDB(mp));
54
54
        mp->m_dirleafblk = XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_LEAF_FIRSTDB(mp));
55
55
        mp->m_dirfreeblk = XFS_DIR2_DB_TO_DA(mp, XFS_DIR2_FREE_FIRSTDB(mp));
56
 
        mp->m_da_node_ents =
 
56
        mp->m_attr_node_ents =
 
57
                (mp->m_sb.sb_blocksize - (uint)sizeof(xfs_da_node_hdr_t)) /
 
58
                (uint)sizeof(xfs_da_node_entry_t);
 
59
        mp->m_dir_node_ents =
57
60
                (mp->m_dirblksize - (uint)sizeof(xfs_da_node_hdr_t)) /
58
61
                (uint)sizeof(xfs_da_node_entry_t);
59
62
        mp->m_dir_magicpct = (mp->m_dirblksize * 37) / 100;
71
74
        xfs_da_args_t   args;           /* operation arguments */
72
75
        int             error;          /* error return value */
73
76
 
74
 
        bzero((char *)&args, sizeof(args));
 
77
        memset((char *)&args, 0, sizeof(args));
75
78
        args.dp = dp;
76
79
        args.trans = tp;
77
 
        ASSERT((dp->i_d.di_mode & IFMT) == IFDIR);
 
80
        ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
78
81
        if ((error = xfs_dir_ino_validate(tp->t_mountp, pdp->i_ino))) {
79
82
                return error;
80
83
        }
99
102
        int                     rval;           /* return value */
100
103
        int                     v;              /* type-checking value */
101
104
 
102
 
        ASSERT((dp->i_d.di_mode & IFMT) == IFDIR);
 
105
        ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
103
106
        if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum))) {
104
107
                return rval;
105
108
        }
106
 
        XFS_STATS_INC(xfsstats.xs_dir_create);
 
109
        XFS_STATS_INC(xs_dir_create);
107
110
        /*
108
111
         * Fill in the arg structure for this request.
109
112
         */
152
155
        int             rval;           /* return value */
153
156
        int             v;              /* type-checking value */
154
157
 
155
 
        ASSERT((dp->i_d.di_mode & IFMT) == IFDIR);
156
 
        if (namelen >= MAXNAMELEN) {
157
 
                return XFS_ERROR(EINVAL);
158
 
        }
159
 
        XFS_STATS_INC(xfsstats.xs_dir_lookup);
 
158
        ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
 
159
        XFS_STATS_INC(xs_dir_lookup);
 
160
 
160
161
        /*
161
162
         * Fill in the arg structure for this request.
162
163
         */
212
213
        int             rval;           /* return value */
213
214
        int             v;              /* type-checking value */
214
215
 
215
 
        ASSERT((dp->i_d.di_mode & IFMT) == IFDIR);
216
 
        XFS_STATS_INC(xfsstats.xs_dir_remove);
 
216
        ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
 
217
        XFS_STATS_INC(xs_dir_remove);
217
218
        /*
218
219
         * Fill in the arg structure for this request.
219
220
         */
264
265
        int             rval;           /* return value */
265
266
        int             v;              /* type-checking value */
266
267
 
267
 
        ASSERT((dp->i_d.di_mode & IFMT) == IFDIR);
268
 
        if (namelen >= MAXNAMELEN) {
269
 
                return XFS_ERROR(EINVAL);
270
 
        }
 
268
        ASSERT((dp->i_d.di_mode & S_IFMT) == S_IFDIR);
 
269
 
271
270
        if ((rval = xfs_dir_ino_validate(tp->t_mountp, inum))) {
272
271
                return rval;
273
272
        }
532
531
                 * and not binval it.
533
532
                 * So the block has to be in a consistent empty state
534
533
                 * and appropriately logged.
535
 
                 * We don't free up the buffer, the caller can tell it 
 
534
                 * We don't free up the buffer, the caller can tell it
536
535
                 * hasn't happened since it got an error back.
537
536
                 */
538
537
                return error;
545
544
        /*
546
545
         * If it's not a data block, we're done.
547
546
         */
548
 
        if (db >= XFS_DIR2_LEAF_FIRSTDB(mp)) 
 
547
        if (db >= XFS_DIR2_LEAF_FIRSTDB(mp))
549
548
                return 0;
550
549
        /*
551
550
         * If the block isn't the last one in the directory, we're done.