summaryrefslogtreecommitdiffstats
path: root/kernel/include/linux/sysv_fs.h
blob: e47d6d90023dbd55794134f8a86035c8e629820e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
#ifndef _LINUX_SYSV_FS_H
#define _LINUX_SYSV_FS_H

#define __packed2__	__attribute__((packed, aligned(2)))


#ifndef __KERNEL__
typedef u16 __fs16;
typedef u32 __fs16;
#endif

/* inode numbers are 16 bit */
typedef __fs16 sysv_ino_t;

/* Block numbers are 24 bit, sometimes stored in 32 bit.
   On Coherent FS, they are always stored in PDP-11 manner: the least
   significant 16 bits come last. */
typedef __fs32 sysv_zone_t;

/* 0 is non-existent */
#define SYSV_BADBL_INO	1	/* inode of bad blocks file */
#define SYSV_ROOT_INO	2	/* inode of root directory */


/* Xenix super-block data on disk */
#define XENIX_NICINOD	100	/* number of inode cache entries */
#define XENIX_NICFREE	100	/* number of free block list chunk entries */
struct xenix_super_block {
	__fs16		s_isize; /* index of first data zone */
	__fs32		s_fsize __packed2__; /* total number of zones of this fs */
	/* the start of the free block list: */
	__fs16		s_nfree;	/* number of free blocks in s_free, <= XENIX_NICFREE */
	sysv_zone_t	s_free[XENIX_NICFREE]; /* first free block list chunk */
	/* the cache of free inodes: */
	__fs16		s_ninode; /* number of free inodes in s_inode, <= XENIX_NICINOD */
	sysv_ino_t	s_inode[XENIX_NICINOD]; /* some free inodes */
	/* locks, not used by Linux: */
	char		s_flock;	/* lock during free block list manipulation */
	char		s_ilock;	/* lock during inode cache manipulation */
	char		s_fmod;		/* super-block modified flag */
	char		s_ronly;	/* flag whether fs is mounted read-only */
	__fs32		s_time __packed2__; /* time of last super block update */
	__fs32		s_tfree __packed2__; /* total number of free zones */
	__fs16		s_tinode;	/* total number of free inodes */
	__fs16		s_dinfo[4];	/* device information ?? */
	char		s_fname[6];	/* file system volume name */
	char		s_fpack[6];	/* file system pack name */
	char		s_clean;	/* set to 0x46 when filesystem is properly unmounted */
	char		s_fill[371];
	s32		s_magic;	/* version of file system */
	__fs32		s_type;		/* type of file system: 1 for 512 byte blocks
								2 for 1024 byte blocks
								3 for 2048 byte blocks */
								
};

/*
 * SystemV FS comes in two variants:
 * sysv2: System V Release 2 (e.g. Microport), structure elements aligned(2).
 * sysv4: System V Release 4 (e.g. Consensys), structure elements aligned(4).
 */
#define SYSV_NICINOD	100	/* number of inode cache entries */
#define SYSV_NICFREE	50	/* number of free block list chunk entries */

/* SystemV4 super-block data on disk */
struct sysv4_super_block {
	__fs16	s_isize;	/* index of first data zone */
	u16	s_pad0;
	__fs32	s_fsize;	/* total number of zones of this fs */
	/* the start of the free block list: */
	__fs16	s_nfree;	/* number of free blocks in s_free, <= SYSV_NICFREE */
	u16	s_pad1;
	sysv_zone_t	s_free[SYSV_NICFREE]; /* first free block list chunk */
	/* the cache of free inodes: */
	__fs16	s_ninode;	/* number of free inodes in s_inode, <= SYSV_NICINOD */
	u16	s_pad2;
	sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
	/* locks, not used by Linux: */
	char	s_flock;	/* lock during free block list manipulation */
	char	s_ilock;	/* lock during inode cache manipulation */
	char	s_fmod;		/* super-block modified flag */
	char	s_ronly;	/* flag whether fs is mounted read-only */
	__fs32	s_time;		/* time of last super block update */
	__fs16	s_dinfo[4];	/* device information ?? */
	__fs32	s_tfree;	/* total number of free zones */
	__fs16	s_tinode;	/* total number of free inodes */
	u16	s_pad3;
	char	s_fname[6];	/* file system volume name */
	char	s_fpack[6];	/* file system pack name */
	s32	s_fill[12];
	__fs32	s_state;	/* file system state: 0x7c269d38-s_time means clean */
	s32	s_magic;	/* version of file system */
	__fs32	s_type;		/* type of file system: 1 for 512 byte blocks
								2 for 1024 byte blocks */
};

/* SystemV2 super-block data on disk */
struct sysv2_super_block {
	__fs16	s_isize; 		/* index of first data zone */
	__fs32	s_fsize __packed2__;	/* total number of zones of this fs */
	/* the start of the free block list: */
	__fs16	s_nfree;		/* number of free blocks in s_free, <= SYSV_NICFREE */
	sysv_zone_t s_free[SYSV_NICFREE];	/* first free block list chunk */
	/* the cache of free inodes: */
	__fs16	s_ninode;		/* number of free inodes in s_inode, <= SYSV_NICINOD */
	sysv_ino_t     s_inode[SYSV_NICINOD]; /* some free inodes */
	/* locks, not used by Linux: */
	char	s_flock;		/* lock during free block list manipulation */
	char	s_ilock;		/* lock during inode cache manipulation */
	char	s_fmod;			/* super-block modified flag */
	char	s_ronly;		/* flag whether fs is mounted read-only */
	__fs32	s_time __packed2__;	/* time of last super block update */
	__fs16	s_dinfo[4];		/* device information ?? */
	__fs32	s_tfree __packed2__;	/* total number of free zones */
	__fs16	s_tinode;		/* total number of free inodes */
	char	s_fname[6];		/* file system volume name */
	char	s_fpack[6];		/* file system pack name */
	s32	s_fill[14];
	__fs32	s_state;		/* file system state: 0xcb096f43 means clean */
	s32	s_magic;		/* version of file system */
	__fs32	s_type;			/* type of file system: 1 for 512 byte blocks
								2 for 1024 byte blocks */
};

/* V7 super-block data on disk */
#define V7_NICINOD     100     /* number of inode cache entries */
#define V7_NICFREE     50      /* number of free block list chunk entries */
struct v7_super_block {
	__fs16 s_isize;        /* index of first data zone */
	__fs32 s_fsize __packed2__; /* total number of zones of this fs */
	/* the start of the free block list: */
	__fs16 s_nfree;        /* number of free blocks in s_free, <= V7_NICFREE */
	sysv_zone_t s_free[V7_NICFREE]; /* first free block list chunk */
	/* the cache of free inodes: */
	__fs16 s_ninode;       /* number of free inodes in s_inode, <= V7_NICINOD */
	sysv_ino_t      s_inode[V7_NICINOD]; /* some free inodes */
	/* locks, not used by Linux or V7: */
	char    s_flock;        /* lock during free block list manipulation */
	char    s_ilock;        /* lock during inode cache manipulation */
	char    s_fmod;         /* super-block modified flag */
	char    s_ronly;        /* flag whether fs is mounted read-only */
	__fs32  s_time __packed2__; /* time of last super block update */
	/* the following fields are not maintained by V7: */
	__fs32  s_tfree __packed2__; /* total number of free zones */
	__fs16  s_tinode;       /* total number of free inodes */
	__fs16  s_m;            /* interleave factor */
	__fs16  s_n;            /* interleave factor */
	char    s_fname[6];     /* file system name */
	char    s_fpack[6];     /* file system pack name */
};
/* Constants to aid sanity checking */
/* This is not a hard limit, nor enforced by v7 kernel. It's actually just
 * the limit used by Seventh Edition's ls, though is high enough to assume
 * that no reasonable file system would have that much entries in root
 * directory. Thus, if we see anything higher, we just probably got the
 * endiannes wrong. */
#define V7_NFILES	1024
/* The disk addresses are three-byte (despite direct block addresses being
 * aligned word-wise in inode). If the most significant byte is non-zero,
 * something is most likely wrong (not a filesystem, bad bytesex). */
#define V7_MAXSIZE	0x00ffffff

/* Coherent super-block data on disk */
#define COH_NICINOD	100	/* number of inode cache entries */
#define COH_NICFREE	64	/* number of free block list chunk entries */
struct coh_super_block {
	__fs16		s_isize;	/* index of first data zone */
	__fs32		s_fsize __packed2__; /* total number of zones of this fs */
	/* the start of the free block list: */
	__fs16 s_nfree;	/* number of free blocks in s_free, <= COH_NICFREE */
	sysv_zone_t	s_free[COH_NICFREE] __packed2__; /* first free block list chunk */
	/* the cache of free inodes: */
	__fs16		s_ninode;	/* number of free inodes in s_inode, <= COH_NICINOD */
	sysv_ino_t	s_inode[COH_NICINOD]; /* some free inodes */
	/* locks, not used by Linux: */
	char		s_flock;	/* lock during free block list manipulation */
	char		s_ilock;	/* lock during inode cache manipulation */
	char		s_fmod;		/* super-block modified flag */
	char		s_ronly;	/* flag whether fs is mounted read-only */
	__fs32		s_time __packed2__; /* time of last super block update */
	__fs32		s_tfree __packed2__; /* total number of free zones */
	__fs16		s_tinode;	/* total number of free inodes */
	__fs16		s_interleave_m;	/* interleave factor */
	__fs16		s_interleave_n;
	char		s_fname[6];	/* file system volume name */
	char		s_fpack[6];	/* file system pack name */
	__fs32		s_unique;	/* zero, not used */
};

/* SystemV/Coherent inode data on disk */
struct sysv_inode {
	__fs16 i_mode;
	__fs16 i_nlink;
	__fs16 i_uid;
	__fs16 i_gid;
	__fs32 i_size;
	u8  i_data[3*(10+1+1+1)];
	u8  i_gen;
	__fs32 i_atime;	/* time of last access */
	__fs32 i_mtime;	/* time of last modification */
	__fs32 i_ctime;	/* time of creation */
};

/* SystemV/Coherent directory entry on disk */
#define SYSV_NAMELEN	14	/* max size of name in struct sysv_dir_entry */
struct sysv_dir_entry {
	sysv_ino_t inode;
	char name[SYSV_NAMELEN]; /* up to 14 characters, the rest are zeroes */
};

#define SYSV_DIRSIZE	sizeof(struct sysv_dir_entry)	/* size of every directory entry */

#endif /* _LINUX_SYSV_FS_H */
class="cm"> */ static inline int rio_write_config_32(struct rio_dev *rdev, u32 offset, u32 data) { return rio_mport_write_config_32(rdev->net->hport, rdev->destid, rdev->hopcount, offset, data); }; /** * rio_read_config_16 - Read 16 bits from configuration space * @rdev: RIO device * @offset: Offset into device configuration space * @data: Pointer to read data into * * Reads 16 bits of data from the specified offset within the * RIO device's configuration space. */ static inline int rio_read_config_16(struct rio_dev *rdev, u32 offset, u16 * data) { return rio_mport_read_config_16(rdev->net->hport, rdev->destid, rdev->hopcount, offset, data); }; /** * rio_write_config_16 - Write 16 bits to configuration space * @rdev: RIO device * @offset: Offset into device configuration space * @data: Data to be written * * Writes 16 bits of data to the specified offset within the * RIO device's configuration space. */ static inline int rio_write_config_16(struct rio_dev *rdev, u32 offset, u16 data) { return rio_mport_write_config_16(rdev->net->hport, rdev->destid, rdev->hopcount, offset, data); }; /** * rio_read_config_8 - Read 8 bits from configuration space * @rdev: RIO device * @offset: Offset into device configuration space * @data: Pointer to read data into * * Reads 8 bits of data from the specified offset within the * RIO device's configuration space. */ static inline int rio_read_config_8(struct rio_dev *rdev, u32 offset, u8 * data) { return rio_mport_read_config_8(rdev->net->hport, rdev->destid, rdev->hopcount, offset, data); }; /** * rio_write_config_8 - Write 8 bits to configuration space * @rdev: RIO device * @offset: Offset into device configuration space * @data: Data to be written * * Writes 8 bits of data to the specified offset within the * RIO device's configuration space. */ static inline int rio_write_config_8(struct rio_dev *rdev, u32 offset, u8 data) { return rio_mport_write_config_8(rdev->net->hport, rdev->destid, rdev->hopcount, offset, data); }; extern int rio_mport_send_doorbell(struct rio_mport *mport, u16 destid, u16 data); /** * rio_send_doorbell - Send a doorbell message to a device * @rdev: RIO device * @data: Doorbell message data * * Send a doorbell message to a RIO device. The doorbell message * has a 16-bit info field provided by the @data argument. */ static inline int rio_send_doorbell(struct rio_dev *rdev, u16 data) { return rio_mport_send_doorbell(rdev->net->hport, rdev->destid, data); }; /** * rio_init_mbox_res - Initialize a RIO mailbox resource * @res: resource struct * @start: start of mailbox range * @end: end of mailbox range * * This function is used to initialize the fields of a resource * for use as a mailbox resource. It initializes a range of * mailboxes using the start and end arguments. */ static inline void rio_init_mbox_res(struct resource *res, int start, int end) { memset(res, 0, sizeof(struct resource)); res->start = start; res->end = end; res->flags = RIO_RESOURCE_MAILBOX; } /** * rio_init_dbell_res - Initialize a RIO doorbell resource * @res: resource struct * @start: start of doorbell range * @end: end of doorbell range * * This function is used to initialize the fields of a resource * for use as a doorbell resource. It initializes a range of * doorbell messages using the start and end arguments. */ static inline void rio_init_dbell_res(struct resource *res, u16 start, u16 end) { memset(res, 0, sizeof(struct resource)); res->start = start; res->end = end; res->flags = RIO_RESOURCE_DOORBELL; } /** * RIO_DEVICE - macro used to describe a specific RIO device * @dev: the 16 bit RIO device ID * @ven: the 16 bit RIO vendor ID * * This macro is used to create a struct rio_device_id that matches a * specific device. The assembly vendor and assembly device fields * will be set to %RIO_ANY_ID. */ #define RIO_DEVICE(dev,ven) \ .did = (dev), .vid = (ven), \ .asm_did = RIO_ANY_ID, .asm_vid = RIO_ANY_ID /* Mailbox management */ extern int rio_request_outb_mbox(struct rio_mport *, void *, int, int, void (*)(struct rio_mport *, void *,int, int)); extern int rio_release_outb_mbox(struct rio_mport *, int); /** * rio_add_outb_message - Add RIO message to an outbound mailbox queue * @mport: RIO master port containing the outbound queue * @rdev: RIO device the message is be sent to * @mbox: The outbound mailbox queue * @buffer: Pointer to the message buffer * @len: Length of the message buffer * * Adds a RIO message buffer to an outbound mailbox queue for * transmission. Returns 0 on success. */ static inline int rio_add_outb_message(struct rio_mport *mport, struct rio_dev *rdev, int mbox, void *buffer, size_t len) { return mport->ops->add_outb_message(mport, rdev, mbox, buffer, len); } extern int rio_request_inb_mbox(struct rio_mport *, void *, int, int, void (*)(struct rio_mport *, void *, int, int)); extern int rio_release_inb_mbox(struct rio_mport *, int); /** * rio_add_inb_buffer - Add buffer to an inbound mailbox queue * @mport: Master port containing the inbound mailbox * @mbox: The inbound mailbox number * @buffer: Pointer to the message buffer * * Adds a buffer to an inbound mailbox queue for reception. Returns * 0 on success. */ static inline int rio_add_inb_buffer(struct rio_mport *mport, int mbox, void *buffer) { return mport->ops->add_inb_buffer(mport, mbox, buffer); } /** * rio_get_inb_message - Get A RIO message from an inbound mailbox queue * @mport: Master port containing the inbound mailbox * @mbox: The inbound mailbox number * * Get a RIO message from an inbound mailbox queue. Returns 0 on success. */ static inline void *rio_get_inb_message(struct rio_mport *mport, int mbox) { return mport->ops->get_inb_message(mport, mbox); } /* Doorbell management */ extern int rio_request_inb_dbell(struct rio_mport *, void *, u16, u16, void (*)(struct rio_mport *, void *, u16, u16, u16)); extern int rio_release_inb_dbell(struct rio_mport *, u16, u16); extern struct resource *rio_request_outb_dbell(struct rio_dev *, u16, u16); extern int rio_release_outb_dbell(struct rio_dev *, struct resource *); /* Memory region management */ int rio_claim_resource(struct rio_dev *, int); int rio_request_regions(struct rio_dev *, char *); void rio_release_regions(struct rio_dev *); int rio_request_region(struct rio_dev *, int, char *); void rio_release_region(struct rio_dev *, int); /* Memory mapping functions */ extern int rio_map_inb_region(struct rio_mport *mport, dma_addr_t local, u64 rbase, u32 size, u32 rflags); extern void rio_unmap_inb_region(struct rio_mport *mport, dma_addr_t lstart); /* Port-Write management */ extern int rio_request_inb_pwrite(struct rio_dev *, int (*)(struct rio_dev *, union rio_pw_msg*, int)); extern int rio_release_inb_pwrite(struct rio_dev *); extern int rio_inb_pwrite_handler(union rio_pw_msg *pw_msg); /* LDM support */ int rio_register_driver(struct rio_driver *); void rio_unregister_driver(struct rio_driver *); struct rio_dev *rio_dev_get(struct rio_dev *); void rio_dev_put(struct rio_dev *); #ifdef CONFIG_RAPIDIO_DMA_ENGINE extern struct dma_chan *rio_request_dma(struct rio_dev *rdev); extern struct dma_chan *rio_request_mport_dma(struct rio_mport *mport); extern void rio_release_dma(struct dma_chan *dchan); extern struct dma_async_tx_descriptor *rio_dma_prep_slave_sg( struct rio_dev *rdev, struct dma_chan *dchan, struct rio_dma_data *data, enum dma_transfer_direction direction, unsigned long flags); extern struct dma_async_tx_descriptor *rio_dma_prep_xfer( struct dma_chan *dchan, u16 destid, struct rio_dma_data *data, enum dma_transfer_direction direction, unsigned long flags); #endif /** * rio_name - Get the unique RIO device identifier * @rdev: RIO device * * Get the unique RIO device identifier. Returns the device * identifier string. */ static inline const char *rio_name(struct rio_dev *rdev) { return dev_name(&rdev->dev); } /** * rio_get_drvdata - Get RIO driver specific data * @rdev: RIO device * * Get RIO driver specific data. Returns a pointer to the * driver specific data. */ static inline void *rio_get_drvdata(struct rio_dev *rdev) { return dev_get_drvdata(&rdev->dev); } /** * rio_set_drvdata - Set RIO driver specific data * @rdev: RIO device * @data: Pointer to driver specific data * * Set RIO driver specific data. device struct driver data pointer * is set to the @data argument. */ static inline void rio_set_drvdata(struct rio_dev *rdev, void *data) { dev_set_drvdata(&rdev->dev, data); } /* Misc driver helpers */ extern u16 rio_local_get_device_id(struct rio_mport *port); extern struct rio_dev *rio_get_device(u16 vid, u16 did, struct rio_dev *from); extern struct rio_dev *rio_get_asm(u16 vid, u16 did, u16 asm_vid, u16 asm_did, struct rio_dev *from); extern int rio_init_mports(void); #endif /* LINUX_RIO_DRV_H */