xref: /openbmc/linux/fs/afs/afs.h (revision dd9fbcb8)
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 
2608e0e7c8SDavid Howells typedef unsigned			afs_volid_t;
2708e0e7c8SDavid Howells typedef unsigned			afs_vnodeid_t;
2808e0e7c8SDavid Howells typedef unsigned long long		afs_dataversion_t;
2908e0e7c8SDavid Howells 
3008e0e7c8SDavid Howells typedef enum {
3108e0e7c8SDavid Howells 	AFSVL_RWVOL,			/* read/write volume */
3208e0e7c8SDavid Howells 	AFSVL_ROVOL,			/* read-only volume */
3308e0e7c8SDavid Howells 	AFSVL_BACKVOL,			/* backup volume */
3408e0e7c8SDavid Howells } __attribute__((packed)) afs_voltype_t;
3508e0e7c8SDavid Howells 
3608e0e7c8SDavid Howells typedef enum {
3708e0e7c8SDavid Howells 	AFS_FTYPE_INVALID	= 0,
3808e0e7c8SDavid Howells 	AFS_FTYPE_FILE		= 1,
3908e0e7c8SDavid Howells 	AFS_FTYPE_DIR		= 2,
4008e0e7c8SDavid Howells 	AFS_FTYPE_SYMLINK	= 3,
4108e0e7c8SDavid Howells } afs_file_type_t;
4208e0e7c8SDavid Howells 
43e8d6c554SDavid Howells typedef enum {
44e8d6c554SDavid Howells 	AFS_LOCK_READ		= 0,	/* read lock request */
45e8d6c554SDavid Howells 	AFS_LOCK_WRITE		= 1,	/* write lock request */
46e8d6c554SDavid Howells } afs_lock_type_t;
47e8d6c554SDavid Howells 
48e8d6c554SDavid Howells #define AFS_LOCKWAIT		(5 * 60) /* time until a lock times out (seconds) */
49e8d6c554SDavid Howells 
5008e0e7c8SDavid Howells /*
5108e0e7c8SDavid Howells  * AFS file identifier
5208e0e7c8SDavid Howells  */
5308e0e7c8SDavid Howells struct afs_fid {
5408e0e7c8SDavid Howells 	afs_volid_t	vid;		/* volume ID */
5508e0e7c8SDavid Howells 	afs_vnodeid_t	vnode;		/* file index within volume */
5608e0e7c8SDavid Howells 	unsigned	unique;		/* unique ID number (file index version) */
5708e0e7c8SDavid Howells };
5808e0e7c8SDavid Howells 
5908e0e7c8SDavid Howells /*
6008e0e7c8SDavid Howells  * AFS callback notification
6108e0e7c8SDavid Howells  */
6208e0e7c8SDavid Howells typedef enum {
6308e0e7c8SDavid Howells 	AFSCM_CB_UNTYPED	= 0,	/* no type set on CB break */
6408e0e7c8SDavid Howells 	AFSCM_CB_EXCLUSIVE	= 1,	/* CB exclusive to CM [not implemented] */
6508e0e7c8SDavid Howells 	AFSCM_CB_SHARED		= 2,	/* CB shared by other CM's */
6608e0e7c8SDavid Howells 	AFSCM_CB_DROPPED	= 3,	/* CB promise cancelled by file server */
6708e0e7c8SDavid Howells } afs_callback_type_t;
6808e0e7c8SDavid Howells 
6908e0e7c8SDavid Howells struct afs_callback {
705cf9dd55SDavid Howells 	unsigned		version;	/* Callback version */
715cf9dd55SDavid Howells 	unsigned		expiry;		/* Time at which expires */
725cf9dd55SDavid Howells 	afs_callback_type_t	type;		/* Type of callback */
735cf9dd55SDavid Howells };
745cf9dd55SDavid Howells 
755cf9dd55SDavid Howells struct afs_callback_break {
765cf9dd55SDavid Howells 	struct afs_fid		fid;		/* File identifier */
775cf9dd55SDavid Howells 	struct afs_callback	cb;		/* Callback details */
7808e0e7c8SDavid Howells };
7908e0e7c8SDavid Howells 
8008e0e7c8SDavid Howells #define AFSCBMAX 50	/* maximum callbacks transferred per bulk op */
8108e0e7c8SDavid Howells 
82f044c884SDavid Howells struct afs_uuid {
83f044c884SDavid Howells 	__be32		time_low;			/* low part of timestamp */
84f044c884SDavid Howells 	__be16		time_mid;			/* mid part of timestamp */
85f044c884SDavid Howells 	__be16		time_hi_and_version;		/* high part of timestamp and version  */
8603dc2cfcSDavid Howells 	__s8		clock_seq_hi_and_reserved;	/* clock seq hi and variant */
8703dc2cfcSDavid Howells 	__s8		clock_seq_low;			/* clock seq low */
8803dc2cfcSDavid Howells 	__s8		node[6];			/* spatially unique node ID (MAC addr) */
89f044c884SDavid Howells };
90f044c884SDavid Howells 
9108e0e7c8SDavid Howells /*
9208e0e7c8SDavid Howells  * AFS volume information
9308e0e7c8SDavid Howells  */
9408e0e7c8SDavid Howells struct afs_volume_info {
9508e0e7c8SDavid Howells 	afs_volid_t		vid;		/* volume ID */
9608e0e7c8SDavid Howells 	afs_voltype_t		type;		/* type of this volume */
9708e0e7c8SDavid Howells 	afs_volid_t		type_vids[5];	/* volume ID's for possible types for this vol */
9808e0e7c8SDavid Howells 
9908e0e7c8SDavid Howells 	/* list of fileservers serving this volume */
10008e0e7c8SDavid Howells 	size_t			nservers;	/* number of entries used in servers[] */
10108e0e7c8SDavid Howells 	struct {
10208e0e7c8SDavid Howells 		struct in_addr	addr;		/* fileserver address */
10308e0e7c8SDavid Howells 	} servers[8];
10408e0e7c8SDavid Howells };
10508e0e7c8SDavid Howells 
10608e0e7c8SDavid Howells /*
10700d3b7a4SDavid Howells  * AFS security ACE access mask
10800d3b7a4SDavid Howells  */
10900d3b7a4SDavid Howells typedef u32 afs_access_t;
11000d3b7a4SDavid Howells #define AFS_ACE_READ		0x00000001U	/* - permission to read a file/dir */
11100d3b7a4SDavid Howells #define AFS_ACE_WRITE		0x00000002U	/* - permission to write/chmod a file */
11200d3b7a4SDavid Howells #define AFS_ACE_INSERT		0x00000004U	/* - permission to create dirent in a dir */
11300d3b7a4SDavid Howells #define AFS_ACE_LOOKUP		0x00000008U	/* - permission to lookup a file/dir in a dir */
11400d3b7a4SDavid Howells #define AFS_ACE_DELETE		0x00000010U	/* - permission to delete a dirent from a dir */
11500d3b7a4SDavid Howells #define AFS_ACE_LOCK		0x00000020U	/* - permission to lock a file */
11600d3b7a4SDavid Howells #define AFS_ACE_ADMINISTER	0x00000040U	/* - permission to change ACL */
11700d3b7a4SDavid Howells #define AFS_ACE_USER_A		0x01000000U	/* - 'A' user-defined permission */
11800d3b7a4SDavid Howells #define AFS_ACE_USER_B		0x02000000U	/* - 'B' user-defined permission */
11900d3b7a4SDavid Howells #define AFS_ACE_USER_C		0x04000000U	/* - 'C' user-defined permission */
12000d3b7a4SDavid Howells #define AFS_ACE_USER_D		0x08000000U	/* - 'D' user-defined permission */
12100d3b7a4SDavid Howells #define AFS_ACE_USER_E		0x10000000U	/* - 'E' user-defined permission */
12200d3b7a4SDavid Howells #define AFS_ACE_USER_F		0x20000000U	/* - 'F' user-defined permission */
12300d3b7a4SDavid Howells #define AFS_ACE_USER_G		0x40000000U	/* - 'G' user-defined permission */
12400d3b7a4SDavid Howells #define AFS_ACE_USER_H		0x80000000U	/* - 'H' user-defined permission */
12500d3b7a4SDavid Howells 
12600d3b7a4SDavid Howells /*
12708e0e7c8SDavid Howells  * AFS file status information
12808e0e7c8SDavid Howells  */
12908e0e7c8SDavid Howells struct afs_file_status {
1305cf9dd55SDavid Howells 	u64			size;		/* file size */
1315cf9dd55SDavid Howells 	afs_dataversion_t	data_version;	/* current data version */
1325cf9dd55SDavid Howells 	time_t			mtime_client;	/* last time client changed data */
1335cf9dd55SDavid Howells 	time_t			mtime_server;	/* last time server changed data */
1345cf9dd55SDavid Howells 	unsigned		abort_code;	/* Abort if bulk-fetching this failed */
13508e0e7c8SDavid Howells 
13608e0e7c8SDavid Howells 	afs_file_type_t		type;		/* file type */
13708e0e7c8SDavid Howells 	unsigned		nlink;		/* link count */
138260a9803SDavid Howells 	u32			author;		/* author ID */
139dd9fbcb8SDavid Howells 	u32			owner;		/* owner ID */
140dd9fbcb8SDavid Howells 	u32			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 */
144e8d6c554SDavid Howells 	s32			lock_count;	/* file lock count (0=UNLK -1=WRLCK +ve=#RDLCK */
14508e0e7c8SDavid Howells };
14608e0e7c8SDavid Howells 
14708e0e7c8SDavid Howells /*
148260a9803SDavid Howells  * AFS file status change request
149260a9803SDavid Howells  */
150260a9803SDavid Howells 
151260a9803SDavid Howells #define AFS_SET_MTIME		0x01		/* set the mtime */
152260a9803SDavid Howells #define AFS_SET_OWNER		0x02		/* set the owner ID */
153260a9803SDavid Howells #define AFS_SET_GROUP		0x04		/* set the group ID (unsupported?) */
154260a9803SDavid Howells #define AFS_SET_MODE		0x08		/* set the UNIX mode */
155260a9803SDavid Howells #define AFS_SET_SEG_SIZE	0x10		/* set the segment size (unsupported) */
156260a9803SDavid Howells 
157260a9803SDavid Howells /*
15808e0e7c8SDavid Howells  * AFS volume synchronisation information
15908e0e7c8SDavid Howells  */
16008e0e7c8SDavid Howells struct afs_volsync {
16108e0e7c8SDavid Howells 	time_t			creation;	/* volume creation time */
16208e0e7c8SDavid Howells };
16308e0e7c8SDavid Howells 
16445222b9eSDavid Howells /*
16545222b9eSDavid Howells  * AFS volume status record
16645222b9eSDavid Howells  */
16745222b9eSDavid Howells struct afs_volume_status {
16845222b9eSDavid Howells 	u32			vid;		/* volume ID */
16945222b9eSDavid Howells 	u32			parent_id;	/* parent volume ID */
17045222b9eSDavid Howells 	u8			online;		/* true if volume currently online and available */
17145222b9eSDavid Howells 	u8			in_service;	/* true if volume currently in service */
17245222b9eSDavid Howells 	u8			blessed;	/* same as in_service */
17345222b9eSDavid Howells 	u8			needs_salvage;	/* true if consistency checking required */
17445222b9eSDavid Howells 	u32			type;		/* volume type (afs_voltype_t) */
17545222b9eSDavid Howells 	u32			min_quota;	/* minimum space set aside (blocks) */
17645222b9eSDavid Howells 	u32			max_quota;	/* maximum space this volume may occupy (blocks) */
17745222b9eSDavid Howells 	u32			blocks_in_use;	/* space this volume currently occupies (blocks) */
17845222b9eSDavid Howells 	u32			part_blocks_avail; /* space available in volume's partition */
17945222b9eSDavid Howells 	u32			part_max_blocks; /* size of volume's partition */
18045222b9eSDavid Howells };
18145222b9eSDavid Howells 
18245222b9eSDavid Howells #define AFS_BLOCK_SIZE	1024
18345222b9eSDavid Howells 
18491a90380SDavid Howells /*
18591a90380SDavid Howells  * XDR encoding of UUID in AFS.
18691a90380SDavid Howells  */
18791a90380SDavid Howells struct afs_uuid__xdr {
18891a90380SDavid Howells 	__be32		time_low;
18991a90380SDavid Howells 	__be32		time_mid;
19091a90380SDavid Howells 	__be32		time_hi_and_version;
19191a90380SDavid Howells 	__be32		clock_seq_hi_and_reserved;
19291a90380SDavid Howells 	__be32		clock_seq_low;
19391a90380SDavid Howells 	__be32		node[6];
19491a90380SDavid Howells };
19591a90380SDavid Howells 
19608e0e7c8SDavid Howells #endif /* AFS_H */
197