18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* AFS fileserver XDR types 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved. 58c2ecf20Sopenharmony_ci * Written by David Howells (dhowells@redhat.com) 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef XDR_FS_H 98c2ecf20Sopenharmony_ci#define XDR_FS_H 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_cistruct afs_xdr_AFSFetchStatus { 128c2ecf20Sopenharmony_ci __be32 if_version; 138c2ecf20Sopenharmony_ci#define AFS_FSTATUS_VERSION 1 148c2ecf20Sopenharmony_ci __be32 type; 158c2ecf20Sopenharmony_ci __be32 nlink; 168c2ecf20Sopenharmony_ci __be32 size_lo; 178c2ecf20Sopenharmony_ci __be32 data_version_lo; 188c2ecf20Sopenharmony_ci __be32 author; 198c2ecf20Sopenharmony_ci __be32 owner; 208c2ecf20Sopenharmony_ci __be32 caller_access; 218c2ecf20Sopenharmony_ci __be32 anon_access; 228c2ecf20Sopenharmony_ci __be32 mode; 238c2ecf20Sopenharmony_ci __be32 parent_vnode; 248c2ecf20Sopenharmony_ci __be32 parent_unique; 258c2ecf20Sopenharmony_ci __be32 seg_size; 268c2ecf20Sopenharmony_ci __be32 mtime_client; 278c2ecf20Sopenharmony_ci __be32 mtime_server; 288c2ecf20Sopenharmony_ci __be32 group; 298c2ecf20Sopenharmony_ci __be32 sync_counter; 308c2ecf20Sopenharmony_ci __be32 data_version_hi; 318c2ecf20Sopenharmony_ci __be32 lock_count; 328c2ecf20Sopenharmony_ci __be32 size_hi; 338c2ecf20Sopenharmony_ci __be32 abort_code; 348c2ecf20Sopenharmony_ci} __packed; 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci#define AFS_DIR_HASHTBL_SIZE 128 378c2ecf20Sopenharmony_ci#define AFS_DIR_DIRENT_SIZE 32 388c2ecf20Sopenharmony_ci#define AFS_DIR_SLOTS_PER_BLOCK 64 398c2ecf20Sopenharmony_ci#define AFS_DIR_BLOCK_SIZE 2048 408c2ecf20Sopenharmony_ci#define AFS_DIR_BLOCKS_PER_PAGE (PAGE_SIZE / AFS_DIR_BLOCK_SIZE) 418c2ecf20Sopenharmony_ci#define AFS_DIR_MAX_SLOTS 65536 428c2ecf20Sopenharmony_ci#define AFS_DIR_BLOCKS_WITH_CTR 128 438c2ecf20Sopenharmony_ci#define AFS_DIR_MAX_BLOCKS 1023 448c2ecf20Sopenharmony_ci#define AFS_DIR_RESV_BLOCKS 1 458c2ecf20Sopenharmony_ci#define AFS_DIR_RESV_BLOCKS0 13 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* 488c2ecf20Sopenharmony_ci * Directory entry structure. 498c2ecf20Sopenharmony_ci */ 508c2ecf20Sopenharmony_ciunion afs_xdr_dirent { 518c2ecf20Sopenharmony_ci struct { 528c2ecf20Sopenharmony_ci u8 valid; 538c2ecf20Sopenharmony_ci u8 unused[1]; 548c2ecf20Sopenharmony_ci __be16 hash_next; 558c2ecf20Sopenharmony_ci __be32 vnode; 568c2ecf20Sopenharmony_ci __be32 unique; 578c2ecf20Sopenharmony_ci u8 name[16]; 588c2ecf20Sopenharmony_ci u8 overflow[4]; /* if any char of the name (inc 598c2ecf20Sopenharmony_ci * NUL) reaches here, consume 608c2ecf20Sopenharmony_ci * the next dirent too */ 618c2ecf20Sopenharmony_ci } u; 628c2ecf20Sopenharmony_ci u8 extended_name[32]; 638c2ecf20Sopenharmony_ci} __packed; 648c2ecf20Sopenharmony_ci 658c2ecf20Sopenharmony_ci/* 668c2ecf20Sopenharmony_ci * Directory block header (one at the beginning of every 2048-byte block). 678c2ecf20Sopenharmony_ci */ 688c2ecf20Sopenharmony_cistruct afs_xdr_dir_hdr { 698c2ecf20Sopenharmony_ci __be16 npages; 708c2ecf20Sopenharmony_ci __be16 magic; 718c2ecf20Sopenharmony_ci#define AFS_DIR_MAGIC htons(1234) 728c2ecf20Sopenharmony_ci u8 reserved; 738c2ecf20Sopenharmony_ci u8 bitmap[8]; 748c2ecf20Sopenharmony_ci u8 pad[19]; 758c2ecf20Sopenharmony_ci} __packed; 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci/* 788c2ecf20Sopenharmony_ci * Directory block layout 798c2ecf20Sopenharmony_ci */ 808c2ecf20Sopenharmony_ciunion afs_xdr_dir_block { 818c2ecf20Sopenharmony_ci struct afs_xdr_dir_hdr hdr; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci struct { 848c2ecf20Sopenharmony_ci struct afs_xdr_dir_hdr hdr; 858c2ecf20Sopenharmony_ci u8 alloc_ctrs[AFS_DIR_MAX_BLOCKS]; 868c2ecf20Sopenharmony_ci __be16 hashtable[AFS_DIR_HASHTBL_SIZE]; 878c2ecf20Sopenharmony_ci } meta; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci union afs_xdr_dirent dirents[AFS_DIR_SLOTS_PER_BLOCK]; 908c2ecf20Sopenharmony_ci} __packed; 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci/* 938c2ecf20Sopenharmony_ci * Directory layout on a linux VM page. 948c2ecf20Sopenharmony_ci */ 958c2ecf20Sopenharmony_cistruct afs_xdr_dir_page { 968c2ecf20Sopenharmony_ci union afs_xdr_dir_block blocks[AFS_DIR_BLOCKS_PER_PAGE]; 978c2ecf20Sopenharmony_ci}; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#endif /* XDR_FS_H */ 100