Dave Chinner | 32c5483 | 2013-10-29 22:11:46 +1100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc. |
| 3 | * Copyright (c) 2013 Red Hat, Inc. |
| 4 | * All Rights Reserved. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public License as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it would be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | #include "xfs.h" |
| 20 | #include "xfs_fs.h" |
| 21 | #include "xfs_format.h" |
| 22 | #include "xfs_log_format.h" |
| 23 | #include "xfs_trans_resv.h" |
| 24 | #include "xfs_sb.h" |
| 25 | #include "xfs_ag.h" |
| 26 | #include "xfs_mount.h" |
| 27 | #include "xfs_da_format.h" |
| 28 | #include "xfs_inode.h" |
| 29 | #include "xfs_dir2.h" |
| 30 | |
| 31 | |
| 32 | static int |
| 33 | xfs_dir2_sf_entsize( |
| 34 | struct xfs_dir2_sf_hdr *hdr, |
| 35 | int len) |
| 36 | { |
| 37 | int count = sizeof(struct xfs_dir2_sf_entry); /* namelen + offset */ |
| 38 | |
| 39 | count += len; /* name */ |
| 40 | count += hdr->i8count ? sizeof(xfs_dir2_ino8_t) : |
| 41 | sizeof(xfs_dir2_ino4_t); /* ino # */ |
| 42 | return count; |
| 43 | } |
| 44 | |
| 45 | static int |
| 46 | xfs_dir3_sf_entsize( |
| 47 | struct xfs_dir2_sf_hdr *hdr, |
| 48 | int len) |
| 49 | { |
| 50 | return xfs_dir2_sf_entsize(hdr, len) + sizeof(__uint8_t); |
| 51 | } |
| 52 | |
| 53 | static struct xfs_dir2_sf_entry * |
| 54 | xfs_dir2_sf_nextentry( |
| 55 | struct xfs_dir2_sf_hdr *hdr, |
| 56 | struct xfs_dir2_sf_entry *sfep) |
| 57 | { |
| 58 | return (struct xfs_dir2_sf_entry *) |
| 59 | ((char *)sfep + xfs_dir2_sf_entsize(hdr, sfep->namelen)); |
| 60 | } |
| 61 | |
| 62 | static struct xfs_dir2_sf_entry * |
| 63 | xfs_dir3_sf_nextentry( |
| 64 | struct xfs_dir2_sf_hdr *hdr, |
| 65 | struct xfs_dir2_sf_entry *sfep) |
| 66 | { |
| 67 | return (struct xfs_dir2_sf_entry *) |
| 68 | ((char *)sfep + xfs_dir3_sf_entsize(hdr, sfep->namelen)); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | const struct xfs_dir_ops xfs_dir2_ops = { |
| 73 | .sf_entsize = xfs_dir2_sf_entsize, |
| 74 | .sf_nextentry = xfs_dir2_sf_nextentry, |
| 75 | }; |
| 76 | |
| 77 | const struct xfs_dir_ops xfs_dir2_ftype_ops = { |
| 78 | .sf_entsize = xfs_dir3_sf_entsize, |
| 79 | .sf_nextentry = xfs_dir3_sf_nextentry, |
| 80 | }; |
| 81 | |
| 82 | const struct xfs_dir_ops xfs_dir3_ops = { |
| 83 | .sf_entsize = xfs_dir3_sf_entsize, |
| 84 | .sf_nextentry = xfs_dir3_sf_nextentry, |
| 85 | }; |