2
* Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
2
* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
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
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License as
6
7
* published by the Free Software Foundation.
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.
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.
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.
23
* Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24
* Mountain View, CA 94043, or:
28
* For further information regarding this notice, see:
30
* http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
9
* This program is distributed in the hope that it would be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write the Free Software Foundation,
16
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
101
87
bf = block->hdr.bestfree;
102
88
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
103
blp = XFS_DIR2_BLOCK_LEAF_P_ARCH(btp, ARCH_CONVERT);
89
blp = XFS_DIR2_BLOCK_LEAF_P(btp);
105
91
* No stale entries? Need space for entry and new leaf.
107
if (INT_ISZERO(btp->stale, ARCH_CONVERT)) {
109
95
* Tag just before the first leaf entry.
425
411
mp = tp->t_mountp;
426
412
block = bp->data;
427
413
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
428
blp = XFS_DIR2_BLOCK_LEAF_P_ARCH(btp, ARCH_CONVERT);
414
blp = XFS_DIR2_BLOCK_LEAF_P(btp);
429
415
xfs_da_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)block),
430
416
(uint)((char *)&blp[last + 1] - (char *)block - 1));
479
465
block = bp->data;
480
466
xfs_dir2_data_check(dp, bp);
481
467
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
482
blp = XFS_DIR2_BLOCK_LEAF_P_ARCH(btp, ARCH_CONVERT);
468
blp = XFS_DIR2_BLOCK_LEAF_P(btp);
484
470
* Get the offset from the leaf entry, to point to the data.
531
517
block = bp->data;
532
518
xfs_dir2_data_check(dp, bp);
533
519
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
534
blp = XFS_DIR2_BLOCK_LEAF_P_ARCH(btp, ARCH_CONVERT);
520
blp = XFS_DIR2_BLOCK_LEAF_P(btp);
536
522
* Loop doing a binary search for our hash value.
537
523
* Find our entry, ENOENT if it's not there.
776
762
* These will show up in the leaf bests table.
778
764
while (dp->i_d.di_size > mp->m_dirblksize) {
779
bestsp = XFS_DIR2_LEAF_BESTS_P_ARCH(ltp, ARCH_CONVERT);
765
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
780
766
if (INT_GET(bestsp[INT_GET(ltp->bestcount, ARCH_CONVERT) - 1], ARCH_CONVERT) ==
781
767
mp->m_dirblksize - (uint)sizeof(block->hdr)) {
832
818
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
833
819
INT_SET(btp->count, ARCH_CONVERT, INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT));
834
INT_ZERO(btp->stale, ARCH_CONVERT);
835
821
xfs_dir2_block_log_tail(tp, dbp);
837
823
* Initialize the block leaf area. We compact out stale entries.
839
lep = XFS_DIR2_BLOCK_LEAF_P_ARCH(btp, ARCH_CONVERT);
825
lep = XFS_DIR2_BLOCK_LEAF_P(btp);
840
826
for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) {
841
827
if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
978
964
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
979
965
INT_SET(btp->count, ARCH_CONVERT, INT_GET(sfp->hdr.count, ARCH_CONVERT) + 2); /* ., .. */
980
INT_ZERO(btp->stale, ARCH_CONVERT);
981
blp = XFS_DIR2_BLOCK_LEAF_P_ARCH(btp, ARCH_CONVERT);
967
blp = XFS_DIR2_BLOCK_LEAF_P(btp);
982
968
endoffset = (uint)((char *)blp - (char *)block);
984
970
* Remove the freespace, we'll manage it.
1005
991
dep = (xfs_dir2_data_entry_t *)
1006
992
((char *)block + XFS_DIR2_DATA_DOTDOT_OFFSET);
1007
INT_SET(dep->inumber, ARCH_CONVERT, XFS_DIR2_SF_GET_INUMBER_ARCH(sfp, &sfp->hdr.parent, ARCH_CONVERT));
993
INT_SET(dep->inumber, ARCH_CONVERT, XFS_DIR2_SF_GET_INUMBER(sfp, &sfp->hdr.parent));
1008
994
dep->namelen = 2;
1009
995
dep->name[0] = dep->name[1] = '.';
1010
996
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
1040
1026
((char *)block + offset);
1041
1027
INT_SET(dup->freetag, ARCH_CONVERT, XFS_DIR2_DATA_FREE_TAG);
1042
1028
INT_SET(dup->length, ARCH_CONVERT, newoffset - offset);
1043
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P_ARCH(dup, ARCH_CONVERT), ARCH_CONVERT,
1029
INT_SET(*XFS_DIR2_DATA_UNUSED_TAG_P(dup), ARCH_CONVERT,
1044
1030
(xfs_dir2_data_off_t)
1045
1031
((char *)dup - (char *)block));
1046
1032
xfs_dir2_data_log_unused(tp, bp, dup);
1053
1039
* Copy a real entry.
1055
1041
dep = (xfs_dir2_data_entry_t *)((char *)block + newoffset);
1056
INT_SET(dep->inumber, ARCH_CONVERT, XFS_DIR2_SF_GET_INUMBER_ARCH(sfp,
1057
XFS_DIR2_SF_INUMBERP(sfep), ARCH_CONVERT));
1042
INT_SET(dep->inumber, ARCH_CONVERT, XFS_DIR2_SF_GET_INUMBER(sfp,
1043
XFS_DIR2_SF_INUMBERP(sfep)));
1058
1044
dep->namelen = sfep->namelen;
1059
1045
memcpy(dep->name, sfep->name, dep->namelen);
1060
1046
tagp = XFS_DIR2_DATA_ENTRY_TAG_P(dep);
1075
1061
* Sort the leaf entries by hash value.
1077
qsort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort);
1063
xfs_sort(blp, INT_GET(btp->count, ARCH_CONVERT), sizeof(*blp), xfs_dir2_block_sort);
1079
1065
* Log the leaf entry area and tail.
1080
1066
* Already logged the header in data_init, ignore needlog.