xref: /openbmc/linux/fs/afs/afs.h (revision 87182759)
108e0e7c8SDavid Howells /* AFS common types
208e0e7c8SDavid Howells  *
308e0e7c8SDavid Howells  * Copyright (C) 2002, 2007 Red Hat, Inc. All Rights Reserved.
408e0e7c8SDavid Howells  * Written by David Howells (dhowells@redhat.com)
508e0e7c8SDavid Howells  *
608e0e7c8SDavid Howells  * This program is free software; you can redistribute it and/or
708e0e7c8SDavid Howells  * modify it under the terms of the GNU General Public License
808e0e7c8SDavid Howells  * as published by the Free Software Foundation; either version
908e0e7c8SDavid Howells  * 2 of the License, or (at your option) any later version.
1008e0e7c8SDavid Howells  */
1108e0e7c8SDavid Howells 
1208e0e7c8SDavid Howells #ifndef AFS_H
1308e0e7c8SDavid Howells #define AFS_H
1408e0e7c8SDavid Howells 
1508e0e7c8SDavid Howells #include <linux/in.h>
1608e0e7c8SDavid Howells 
1791a90380SDavid Howells #define AFS_MAXCELLNAME		64  	/* Maximum length of a cell name */
1891a90380SDavid Howells #define AFS_MAXVOLNAME		64  	/* Maximum length of a volume name */
1991a90380SDavid Howells #define AFS_MAXNSERVERS		8   	/* Maximum servers in a basic volume record */
2091a90380SDavid Howells #define AFS_NMAXNSERVERS	13  	/* Maximum servers in a N/U-class volume record */
2191a90380SDavid Howells #define AFS_MAXTYPES		3	/* Maximum number of volume types */
2291a90380SDavid Howells #define AFSNAMEMAX		256 	/* Maximum length of a filename plus NUL */
2391a90380SDavid Howells #define AFSPATHMAX		1024	/* Maximum length of a pathname plus NUL */
2491a90380SDavid Howells #define AFSOPAQUEMAX		1024	/* Maximum length of an opaque field */
2500d3b7a4SDavid Howells 
2694f699c9SDavid Howells #define AFS_VL_MAX_LIFESPAN	(120 * HZ)
2794f699c9SDavid Howells #define AFS_PROBE_MAX_LIFESPAN	(30 * HZ)
2894f699c9SDavid Howells 
293b6492dfSDavid Howells typedef u64			afs_volid_t;
303b6492dfSDavid Howells typedef u64			afs_vnodeid_t;
313b6492dfSDavid Howells typedef u64			afs_dataversion_t;
3208e0e7c8SDavid Howells 
3308e0e7c8SDavid Howells typedef enum {
3408e0e7c8SDavid Howells 	AFSVL_RWVOL,			/* read/write volume */
3508e0e7c8SDavid Howells 	AFSVL_ROVOL,			/* read-only volume */
3608e0e7c8SDavid Howells 	AFSVL_BACKVOL,			/* backup volume */
3708e0e7c8SDavid Howells } __attribute__((packed)) afs_voltype_t;
3808e0e7c8SDavid Howells 
3908e0e7c8SDavid Howells typedef enum {
4008e0e7c8SDavid Howells 	AFS_FTYPE_INVALID	= 0,
4108e0e7c8SDavid Howells 	AFS_FTYPE_FILE		= 1,
4208e0e7c8SDavid Howells 	AFS_FTYPE_DIR		= 2,
4308e0e7c8SDavid Howells 	AFS_FTYPE_SYMLINK	= 3,
4408e0e7c8SDavid Howells } afs_file_type_t;
4508e0e7c8SDavid Howells 
46e8d6c554SDavid Howells typedef enum {
47e8d6c554SDavid Howells 	AFS_LOCK_READ		= 0,	/* read lock request */
48e8d6c554SDavid Howells 	AFS_LOCK_WRITE		= 1,	/* write lock request */
49e8d6c554SDavid Howells } afs_lock_type_t;
50e8d6c554SDavid Howells 
51e8d6c554SDavid Howells #define AFS_LOCKWAIT		(5 * 60) /* time until a lock times out (seconds) */
52e8d6c554SDavid Howells 
5308e0e7c8SDavid Howells /*
5408e0e7c8SDavid Howells  * AFS file identifier
5508e0e7c8SDavid Howells  */
5608e0e7c8SDavid Howells struct afs_fid {
5708e0e7c8SDavid Howells 	afs_volid_t	vid;		/* volume ID */
583b6492dfSDavid Howells 	afs_vnodeid_t	vnode;		/* Lower 64-bits of file index within volume */
593b6492dfSDavid Howells 	u32		vnode_hi;	/* Upper 32-bits of file index */
603b6492dfSDavid Howells 	u32		unique;		/* unique ID number (file index version) */
6108e0e7c8SDavid Howells };
6208e0e7c8SDavid Howells 
6308e0e7c8SDavid Howells /*
6408e0e7c8SDavid Howells  * AFS callback notification
6508e0e7c8SDavid Howells  */
6608e0e7c8SDavid Howells typedef enum {
6708e0e7c8SDavid Howells 	AFSCM_CB_UNTYPED	= 0,	/* no type set on CB break */
6808e0e7c8SDavid Howells 	AFSCM_CB_EXCLUSIVE	= 1,	/* CB exclusive to CM [not implemented] */
6908e0e7c8SDavid Howells 	AFSCM_CB_SHARED		= 2,	/* CB shared by other CM's */
7008e0e7c8SDavid Howells 	AFSCM_CB_DROPPED	= 3,	/* CB promise cancelled by file server */
7108e0e7c8SDavid Howells } afs_callback_type_t;
7208e0e7c8SDavid Howells 
7308e0e7c8SDavid Howells struct afs_callback {
7412d8e95aSDavid Howells 	time64_t		expires_at;	/* Time at which expires */
755cf9dd55SDavid Howells 	unsigned		version;	/* Callback version */
765cf9dd55SDavid Howells 	afs_callback_type_t	type;		/* Type of callback */
775cf9dd55SDavid Howells };
785cf9dd55SDavid Howells 
795cf9dd55SDavid Howells struct afs_callback_break {
805cf9dd55SDavid Howells 	struct afs_fid		fid;		/* File identifier */
8106aeb297SDavid Howells 	//struct afs_callback	cb;		/* Callback details */
8208e0e7c8SDavid Howells };
8308e0e7c8SDavid Howells 
8408e0e7c8SDavid Howells #define AFSCBMAX 50	/* maximum callbacks transferred per bulk op */
8508e0e7c8SDavid Howells 
86f044c884SDavid Howells struct afs_uuid {
87f044c884SDavid Howells 	__be32		time_low;			/* low part of timestamp */
88f044c884SDavid Howells 	__be16		time_mid;			/* mid part of timestamp */
89f044c884SDavid Howells 	__be16		time_hi_and_version;		/* high part of timestamp and version  */
9003dc2cfcSDavid Howells 	__s8		clock_seq_hi_and_reserved;	/* clock seq hi and variant */
9103dc2cfcSDavid Howells 	__s8		clock_seq_low;			/* clock seq low */
9203dc2cfcSDavid Howells 	__s8		node[6];			/* spatially unique node ID (MAC addr) */
93f044c884SDavid Howells };
94f044c884SDavid Howells 
9508e0e7c8SDavid Howells /*
9608e0e7c8SDavid Howells  * AFS volume information
9708e0e7c8SDavid Howells  */
9808e0e7c8SDavid Howells struct afs_volume_info {
9908e0e7c8SDavid Howells 	afs_volid_t		vid;		/* volume ID */
10008e0e7c8SDavid Howells 	afs_voltype_t		type;		/* type of this volume */
10108e0e7c8SDavid Howells 	afs_volid_t		type_vids[5];	/* volume ID's for possible types for this vol */
10208e0e7c8SDavid Howells 
10308e0e7c8SDavid Howells 	/* list of fileservers serving this volume */
10408e0e7c8SDavid Howells 	size_t			nservers;	/* number of entries used in servers[] */
10508e0e7c8SDavid Howells 	struct {
10608e0e7c8SDavid Howells 		struct in_addr	addr;		/* fileserver address */
10708e0e7c8SDavid Howells 	} servers[8];
10808e0e7c8SDavid Howells };
10908e0e7c8SDavid Howells 
11008e0e7c8SDavid Howells /*
11100d3b7a4SDavid Howells  * AFS security ACE access mask
11200d3b7a4SDavid Howells  */
11300d3b7a4SDavid Howells typedef u32 afs_access_t;
11400d3b7a4SDavid Howells #define AFS_ACE_READ		0x00000001U	/* - permission to read a file/dir */
11500d3b7a4SDavid Howells #define AFS_ACE_WRITE		0x00000002U	/* - permission to write/chmod a file */
11600d3b7a4SDavid Howells #define AFS_ACE_INSERT		0x00000004U	/* - permission to create dirent in a dir */
11700d3b7a4SDavid Howells #define AFS_ACE_LOOKUP		0x00000008U	/* - permission to lookup a file/dir in a dir */
11800d3b7a4SDavid Howells #define AFS_ACE_DELETE		0x00000010U	/* - permission to delete a dirent from a dir */
11900d3b7a4SDavid Howells #define AFS_ACE_LOCK		0x00000020U	/* - permission to lock a file */
12000d3b7a4SDavid Howells #define AFS_ACE_ADMINISTER	0x00000040U	/* - permission to change ACL */
12100d3b7a4SDavid Howells #define AFS_ACE_USER_A		0x01000000U	/* - 'A' user-defined permission */
12200d3b7a4SDavid Howells #define AFS_ACE_USER_B		0x02000000U	/* - 'B' user-defined permission */
12300d3b7a4SDavid Howells #define AFS_ACE_USER_C		0x04000000U	/* - 'C' user-defined permission */
12400d3b7a4SDavid Howells #define AFS_ACE_USER_D		0x08000000U	/* - 'D' user-defined permission */
12500d3b7a4SDavid Howells #define AFS_ACE_USER_E		0x10000000U	/* - 'E' user-defined permission */
12600d3b7a4SDavid Howells #define AFS_ACE_USER_F		0x20000000U	/* - 'F' user-defined permission */
12700d3b7a4SDavid Howells #define AFS_ACE_USER_G		0x40000000U	/* - 'G' user-defined permission */
12800d3b7a4SDavid Howells #define AFS_ACE_USER_H		0x80000000U	/* - 'H' user-defined permission */
12900d3b7a4SDavid Howells 
13000d3b7a4SDavid Howells /*
13108e0e7c8SDavid Howells  * AFS file status information
13208e0e7c8SDavid Howells  */
13308e0e7c8SDavid Howells struct afs_file_status {
1345cf9dd55SDavid Howells 	u64			size;		/* file size */
1355cf9dd55SDavid Howells 	afs_dataversion_t	data_version;	/* current data version */
136d4936803SDavid Howells 	struct timespec64	mtime_client;	/* Last time client changed data */
137d4936803SDavid Howells 	struct timespec64	mtime_server;	/* Last time server changed data */
138d4936803SDavid Howells 	s64			author;		/* author ID */
139d4936803SDavid Howells 	s64			owner;		/* owner ID */
140d4936803SDavid Howells 	s64			group;		/* group ID */
14100d3b7a4SDavid Howells 	afs_access_t		caller_access;	/* access rights for authenticated caller */
14200d3b7a4SDavid Howells 	afs_access_t		anon_access;	/* access rights for unauthenticated caller */
14308e0e7c8SDavid Howells 	umode_t			mode;		/* UNIX mode */
144d4936803SDavid Howells 	afs_file_type_t		type;		/* file type */
145d4936803SDavid Howells 	u32			nlink;		/* link count */
146e8d6c554SDavid Howells 	s32			lock_count;	/* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
147d4936803SDavid Howells 	u32			abort_code;	/* Abort if bulk-fetching this failed */
14808e0e7c8SDavid Howells };
14908e0e7c8SDavid Howells 
15087182759SDavid Howells struct afs_status_cb {
15187182759SDavid Howells 	struct afs_file_status	status;
15287182759SDavid Howells 	struct afs_callback	callback;
15387182759SDavid Howells 	bool			have_cb;	/* True if cb record was retrieved */
15487182759SDavid Howells };
15587182759SDavid Howells 
15608e0e7c8SDavid Howells /*
157260a9803SDavid Howells  * AFS file status change request
158260a9803SDavid Howells  */
159260a9803SDavid Howells 
160260a9803SDavid Howells #define AFS_SET_MTIME		0x01		/* set the mtime */
161260a9803SDavid Howells #define AFS_SET_OWNER		0x02		/* set the owner ID */
162260a9803SDavid Howells #define AFS_SET_GROUP		0x04		/* set the group ID (unsupported?) */
163260a9803SDavid Howells #define AFS_SET_MODE		0x08		/* set the UNIX mode */
164260a9803SDavid Howells #define AFS_SET_SEG_SIZE	0x10		/* set the segment size (unsupported) */
165260a9803SDavid Howells 
166260a9803SDavid Howells /*
16708e0e7c8SDavid Howells  * AFS volume synchronisation information
16808e0e7c8SDavid Howells  */
16908e0e7c8SDavid Howells struct afs_volsync {
170d4936803SDavid Howells 	time64_t		creation;	/* volume creation time */
17108e0e7c8SDavid Howells };
17208e0e7c8SDavid Howells 
17345222b9eSDavid Howells /*
17445222b9eSDavid Howells  * AFS volume status record
17545222b9eSDavid Howells  */
17645222b9eSDavid Howells struct afs_volume_status {
177d4936803SDavid Howells 	afs_volid_t		vid;		/* volume ID */
178d4936803SDavid Howells 	afs_volid_t		parent_id;	/* parent volume ID */
17945222b9eSDavid Howells 	u8			online;		/* true if volume currently online and available */
18045222b9eSDavid Howells 	u8			in_service;	/* true if volume currently in service */
18145222b9eSDavid Howells 	u8			blessed;	/* same as in_service */
18245222b9eSDavid Howells 	u8			needs_salvage;	/* true if consistency checking required */
18345222b9eSDavid Howells 	u32			type;		/* volume type (afs_voltype_t) */
184d4936803SDavid Howells 	u64			min_quota;	/* minimum space set aside (blocks) */
185d4936803SDavid Howells 	u64			max_quota;	/* maximum space this volume may occupy (blocks) */
186d4936803SDavid Howells 	u64			blocks_in_use;	/* space this volume currently occupies (blocks) */
187d4936803SDavid Howells 	u64			part_blocks_avail; /* space available in volume's partition */
188d4936803SDavid Howells 	u64			part_max_blocks; /* size of volume's partition */
189d4936803SDavid Howells 	s64			vol_copy_date;
190d4936803SDavid Howells 	s64			vol_backup_date;
19145222b9eSDavid Howells };
19245222b9eSDavid Howells 
19345222b9eSDavid Howells #define AFS_BLOCK_SIZE	1024
19445222b9eSDavid Howells 
19591a90380SDavid Howells /*
19691a90380SDavid Howells  * XDR encoding of UUID in AFS.
19791a90380SDavid Howells  */
19891a90380SDavid Howells struct afs_uuid__xdr {
19991a90380SDavid Howells 	__be32		time_low;
20091a90380SDavid Howells 	__be32		time_mid;
20191a90380SDavid Howells 	__be32		time_hi_and_version;
20291a90380SDavid Howells 	__be32		clock_seq_hi_and_reserved;
20391a90380SDavid Howells 	__be32		clock_seq_low;
20491a90380SDavid Howells 	__be32		node[6];
20591a90380SDavid Howells };
20691a90380SDavid Howells 
20708e0e7c8SDavid Howells #endif /* AFS_H */
208