blob: 94f1f398eefadc0b899d67e23bece7b30da4abeb [file] [log] [blame]
Thomas Gleixnerb4d0d232019-05-20 19:08:01 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
David Howellsdd9fbcb2018-04-06 14:17:24 +01002/* AFS fileserver XDR types
3 *
4 * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells (dhowells@redhat.com)
David Howellsdd9fbcb2018-04-06 14:17:24 +01006 */
7
8#ifndef XDR_FS_H
9#define XDR_FS_H
10
11struct afs_xdr_AFSFetchStatus {
12 __be32 if_version;
13#define AFS_FSTATUS_VERSION 1
14 __be32 type;
15 __be32 nlink;
16 __be32 size_lo;
17 __be32 data_version_lo;
18 __be32 author;
19 __be32 owner;
20 __be32 caller_access;
21 __be32 anon_access;
22 __be32 mode;
23 __be32 parent_vnode;
24 __be32 parent_unique;
25 __be32 seg_size;
26 __be32 mtime_client;
27 __be32 mtime_server;
28 __be32 group;
29 __be32 sync_counter;
30 __be32 data_version_hi;
31 __be32 lock_count;
32 __be32 size_hi;
33 __be32 abort_code;
34} __packed;
35
David Howells4ea219a2018-04-06 14:17:25 +010036#define AFS_DIR_HASHTBL_SIZE 128
37#define AFS_DIR_DIRENT_SIZE 32
38#define AFS_DIR_SLOTS_PER_BLOCK 64
39#define AFS_DIR_BLOCK_SIZE 2048
40#define AFS_DIR_BLOCKS_PER_PAGE (PAGE_SIZE / AFS_DIR_BLOCK_SIZE)
41#define AFS_DIR_MAX_SLOTS 65536
42#define AFS_DIR_BLOCKS_WITH_CTR 128
43#define AFS_DIR_MAX_BLOCKS 1023
44#define AFS_DIR_RESV_BLOCKS 1
45#define AFS_DIR_RESV_BLOCKS0 13
46
47/*
48 * Directory entry structure.
49 */
David Howells00317632018-04-06 14:17:25 +010050union afs_xdr_dirent {
David Howells4ea219a2018-04-06 14:17:25 +010051 struct {
David Howells00317632018-04-06 14:17:25 +010052 u8 valid;
53 u8 unused[1];
David Howells4ea219a2018-04-06 14:17:25 +010054 __be16 hash_next;
55 __be32 vnode;
56 __be32 unique;
David Howells00317632018-04-06 14:17:25 +010057 u8 name[16];
58 u8 overflow[4]; /* if any char of the name (inc
David Howells4ea219a2018-04-06 14:17:25 +010059 * NUL) reaches here, consume
60 * the next dirent too */
61 } u;
David Howells00317632018-04-06 14:17:25 +010062 u8 extended_name[32];
63} __packed;
David Howells4ea219a2018-04-06 14:17:25 +010064
65/*
David Howells00317632018-04-06 14:17:25 +010066 * Directory block header (one at the beginning of every 2048-byte block).
David Howells4ea219a2018-04-06 14:17:25 +010067 */
David Howells00317632018-04-06 14:17:25 +010068struct afs_xdr_dir_hdr {
David Howells4ea219a2018-04-06 14:17:25 +010069 __be16 npages;
70 __be16 magic;
71#define AFS_DIR_MAGIC htons(1234)
David Howells00317632018-04-06 14:17:25 +010072 u8 reserved;
73 u8 bitmap[8];
74 u8 pad[19];
75} __packed;
David Howells4ea219a2018-04-06 14:17:25 +010076
77/*
78 * Directory block layout
79 */
David Howells00317632018-04-06 14:17:25 +010080union afs_xdr_dir_block {
81 struct afs_xdr_dir_hdr hdr;
David Howells4ea219a2018-04-06 14:17:25 +010082
83 struct {
David Howells00317632018-04-06 14:17:25 +010084 struct afs_xdr_dir_hdr hdr;
85 u8 alloc_ctrs[AFS_DIR_MAX_BLOCKS];
David Howells4ea219a2018-04-06 14:17:25 +010086 __be16 hashtable[AFS_DIR_HASHTBL_SIZE];
David Howells00317632018-04-06 14:17:25 +010087 } meta;
David Howells4ea219a2018-04-06 14:17:25 +010088
David Howells00317632018-04-06 14:17:25 +010089 union afs_xdr_dirent dirents[AFS_DIR_SLOTS_PER_BLOCK];
90} __packed;
David Howells4ea219a2018-04-06 14:17:25 +010091
92/*
93 * Directory layout on a linux VM page.
94 */
David Howells00317632018-04-06 14:17:25 +010095struct afs_xdr_dir_page {
96 union afs_xdr_dir_block blocks[AFS_DIR_BLOCKS_PER_PAGE];
David Howells4ea219a2018-04-06 14:17:25 +010097};
98
David Howellsdd9fbcb2018-04-06 14:17:24 +010099#endif /* XDR_FS_H */