David Howells | dd9fbcb | 2018-04-06 14:17:24 +0100 | [diff] [blame] | 1 | /* AFS fileserver XDR types |
| 2 | * |
| 3 | * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved. |
| 4 | * Written by David Howells (dhowells@redhat.com) |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU General Public Licence |
| 8 | * as published by the Free Software Foundation; either version |
| 9 | * 2 of the Licence, or (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #ifndef XDR_FS_H |
| 13 | #define XDR_FS_H |
| 14 | |
| 15 | struct afs_xdr_AFSFetchStatus { |
| 16 | __be32 if_version; |
| 17 | #define AFS_FSTATUS_VERSION 1 |
| 18 | __be32 type; |
| 19 | __be32 nlink; |
| 20 | __be32 size_lo; |
| 21 | __be32 data_version_lo; |
| 22 | __be32 author; |
| 23 | __be32 owner; |
| 24 | __be32 caller_access; |
| 25 | __be32 anon_access; |
| 26 | __be32 mode; |
| 27 | __be32 parent_vnode; |
| 28 | __be32 parent_unique; |
| 29 | __be32 seg_size; |
| 30 | __be32 mtime_client; |
| 31 | __be32 mtime_server; |
| 32 | __be32 group; |
| 33 | __be32 sync_counter; |
| 34 | __be32 data_version_hi; |
| 35 | __be32 lock_count; |
| 36 | __be32 size_hi; |
| 37 | __be32 abort_code; |
| 38 | } __packed; |
| 39 | |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 40 | #define AFS_DIR_HASHTBL_SIZE 128 |
| 41 | #define AFS_DIR_DIRENT_SIZE 32 |
| 42 | #define AFS_DIR_SLOTS_PER_BLOCK 64 |
| 43 | #define AFS_DIR_BLOCK_SIZE 2048 |
| 44 | #define AFS_DIR_BLOCKS_PER_PAGE (PAGE_SIZE / AFS_DIR_BLOCK_SIZE) |
| 45 | #define AFS_DIR_MAX_SLOTS 65536 |
| 46 | #define AFS_DIR_BLOCKS_WITH_CTR 128 |
| 47 | #define AFS_DIR_MAX_BLOCKS 1023 |
| 48 | #define AFS_DIR_RESV_BLOCKS 1 |
| 49 | #define AFS_DIR_RESV_BLOCKS0 13 |
| 50 | |
| 51 | /* |
| 52 | * Directory entry structure. |
| 53 | */ |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 54 | union afs_xdr_dirent { |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 55 | struct { |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 56 | u8 valid; |
| 57 | u8 unused[1]; |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 58 | __be16 hash_next; |
| 59 | __be32 vnode; |
| 60 | __be32 unique; |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 61 | u8 name[16]; |
| 62 | u8 overflow[4]; /* if any char of the name (inc |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 63 | * NUL) reaches here, consume |
| 64 | * the next dirent too */ |
| 65 | } u; |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 66 | u8 extended_name[32]; |
| 67 | } __packed; |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 68 | |
| 69 | /* |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 70 | * Directory block header (one at the beginning of every 2048-byte block). |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 71 | */ |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 72 | struct afs_xdr_dir_hdr { |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 73 | __be16 npages; |
| 74 | __be16 magic; |
| 75 | #define AFS_DIR_MAGIC htons(1234) |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 76 | u8 reserved; |
| 77 | u8 bitmap[8]; |
| 78 | u8 pad[19]; |
| 79 | } __packed; |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 80 | |
| 81 | /* |
| 82 | * Directory block layout |
| 83 | */ |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 84 | union afs_xdr_dir_block { |
| 85 | struct afs_xdr_dir_hdr hdr; |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 86 | |
| 87 | struct { |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 88 | struct afs_xdr_dir_hdr hdr; |
| 89 | u8 alloc_ctrs[AFS_DIR_MAX_BLOCKS]; |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 90 | __be16 hashtable[AFS_DIR_HASHTBL_SIZE]; |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 91 | } meta; |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 92 | |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 93 | union afs_xdr_dirent dirents[AFS_DIR_SLOTS_PER_BLOCK]; |
| 94 | } __packed; |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 95 | |
| 96 | /* |
| 97 | * Directory layout on a linux VM page. |
| 98 | */ |
David Howells | 0031763 | 2018-04-06 14:17:25 +0100 | [diff] [blame^] | 99 | struct afs_xdr_dir_page { |
| 100 | union afs_xdr_dir_block blocks[AFS_DIR_BLOCKS_PER_PAGE]; |
David Howells | 4ea219a | 2018-04-06 14:17:25 +0100 | [diff] [blame] | 101 | }; |
| 102 | |
David Howells | dd9fbcb | 2018-04-06 14:17:24 +0100 | [diff] [blame] | 103 | #endif /* XDR_FS_H */ |