1/* SPDX-License-Identifier: GPL-2.0 */
2#ifndef __CODA_PSDEV_H
3#define __CODA_PSDEV_H
4
5#include <linux/backing-dev.h>
6#include <linux/magic.h>
7#include <linux/mutex.h>
8
9#define CODA_PSDEV_MAJOR 67
10#define MAX_CODADEVS  5	   /* how many do we allow */
11
12struct kstatfs;
13
14/* messages between coda filesystem in kernel and Venus */
15struct upc_req {
16	struct list_head	uc_chain;
17	caddr_t			uc_data;
18	u_short			uc_flags;
19	u_short			uc_inSize;  /* Size is at most 5000 bytes */
20	u_short			uc_outSize;
21	u_short			uc_opcode;  /* copied from data to save lookup */
22	int			uc_unique;
23	wait_queue_head_t	uc_sleep;   /* process' wait queue */
24};
25
26#define CODA_REQ_ASYNC  0x1
27#define CODA_REQ_READ   0x2
28#define CODA_REQ_WRITE  0x4
29#define CODA_REQ_ABORT  0x8
30
31/* communication pending/processing queues */
32struct venus_comm {
33	u_long		    vc_seq;
34	wait_queue_head_t   vc_waitq; /* Venus wait queue */
35	struct list_head    vc_pending;
36	struct list_head    vc_processing;
37	int                 vc_inuse;
38	struct super_block *vc_sb;
39	struct mutex	    vc_mutex;
40};
41
42static inline struct venus_comm *coda_vcp(struct super_block *sb)
43{
44	return (struct venus_comm *)((sb)->s_fs_info);
45}
46
47/* upcalls */
48int venus_rootfid(struct super_block *sb, struct CodaFid *fidp);
49int venus_getattr(struct super_block *sb, struct CodaFid *fid,
50		  struct coda_vattr *attr);
51int venus_setattr(struct super_block *, struct CodaFid *, struct coda_vattr *);
52int venus_lookup(struct super_block *sb, struct CodaFid *fid,
53		 const char *name, int length, int *type,
54		 struct CodaFid *resfid);
55int venus_close(struct super_block *sb, struct CodaFid *fid, int flags,
56		kuid_t uid);
57int venus_open(struct super_block *sb, struct CodaFid *fid, int flags,
58	       struct file **f);
59int venus_mkdir(struct super_block *sb, struct CodaFid *dirfid,
60		const char *name, int length,
61		struct CodaFid *newfid, struct coda_vattr *attrs);
62int venus_create(struct super_block *sb, struct CodaFid *dirfid,
63		 const char *name, int length, int excl, int mode,
64		 struct CodaFid *newfid, struct coda_vattr *attrs);
65int venus_rmdir(struct super_block *sb, struct CodaFid *dirfid,
66		const char *name, int length);
67int venus_remove(struct super_block *sb, struct CodaFid *dirfid,
68		 const char *name, int length);
69int venus_readlink(struct super_block *sb, struct CodaFid *fid,
70		   char *buffer, int *length);
71int venus_rename(struct super_block *sb, struct CodaFid *new_fid,
72		 struct CodaFid *old_fid, size_t old_length,
73		 size_t new_length, const char *old_name,
74		 const char *new_name);
75int venus_link(struct super_block *sb, struct CodaFid *fid,
76		  struct CodaFid *dirfid, const char *name, int len );
77int venus_symlink(struct super_block *sb, struct CodaFid *fid,
78		  const char *name, int len, const char *symname, int symlen);
79int venus_access(struct super_block *sb, struct CodaFid *fid, int mask);
80int venus_pioctl(struct super_block *sb, struct CodaFid *fid,
81		 unsigned int cmd, struct PioctlData *data);
82int coda_downcall(struct venus_comm *vcp, int opcode, union outputArgs *out,
83		  size_t nbytes);
84int venus_fsync(struct super_block *sb, struct CodaFid *fid);
85int venus_statfs(struct dentry *dentry, struct kstatfs *sfs);
86int venus_access_intent(struct super_block *sb, struct CodaFid *fid,
87			bool *access_intent_supported,
88			size_t count, loff_t ppos, int type);
89
90/*
91 * Statistics
92 */
93
94extern struct venus_comm coda_comms[];
95#endif
96