#define PFS_OP_CREATE   1
#define PFS_OP_GETATTR  2 
#define PFS_OP_MKDIR    3
#define PFS_OP_READ     4 
#define PFS_OP_READDIR  5 
#define PFS_OP_REMOVE   6
#define PFS_OP_RENAME   7
#define PFS_OP_RMDIR    8
#define PFS_OP_SETATTR  9
#define PFS_OP_WRITE   10
#define PFS_OP_GETDEVS 11
/* The same as getattr without the stat (for linkcount purposes */
#define PFS_OP_STATDEV 12

typedef struct p_inode
{
  int inode;
  char *name;
  struct p_inode *nextnam, *nextnum;
} p_inode;

struct device
{
  char *name;
  unsigned char attrib[14];
  int total, free;
  struct device *next;
};

struct cache
{
  unsigned char *data;
  unsigned int offset, len, inode;
  int written, actual_size;
  fattr attr;
  struct cache *next;
};

struct entrycache
{
  int inode;
  entry *head;
  struct entrycache *next;
};

extern int psionfd, debug, gmtoffset, exiting, psion_alive, dowakeup;
extern fattr root_fattr;
extern char *disconnprog, *connprog;
extern struct cache *readcache, *writecache, *attrcache;

extern char *index(), *rindex(), *strdup();

extern p_inode *get_num();
extern p_inode *get_nam();
extern p_inode *re_nam();
extern entry ** getfirst();
extern struct cache *search_cache(), *add_cache();
extern char *dirname(), *filname(), *build_path();
extern void inode2fh();


#define THE_END        (struct entry *)-1
#define PBUFSIZE       (NFS_MAXDATA/2)  /* Transfer buffer size */
#define TIMEOUT       -54
#define BLOCKSIZE      512
#define FID            7 /* File system id */

#ifndef __P
# define __P(a) ()
#endif

/* mp_serial.c */
int init_serial __P((char *dev, int speed, int flags));
int fd_is_still_alive __P((int fd, int wake));

/* mp_mount.c */
int mount_and_run __P((char *dir, void (*proc)(), nfs_fh *root_fh));

/* mp_cache.c */
void clean_cache __P((struct cache **root));

/* mp_inode.c */
int fh2inode __P((char *));
int getpinode __P((p_inode *inode));

/* mp_xmit.c */
int sendop __P((int cmd, char *fname, char *rest, int restlen));
int getstr __P((unsigned char *str));
int getbyte __P((void));
int sendcmd __P((int cmd, char *fname, char *rest, int restlen));
int getcount __P((unsigned char *str, int num));
int senddata __P((char *p, int len));
void long2pstr __P((unsigned int l, unsigned char *s));
void short2pstr __P((unsigned int l, unsigned char *s));
unsigned int pstr2long __P((unsigned char *s));

/* mp_pfs_ops.c */
void *nfsproc_null_2 __P((void));
void *nfsproc_root_2 __P((void));
void *nfsproc_writecache_2 __P((void));
nfsstat *nfsproc_link_2 __P((struct linkargs *la));
nfsstat *nfsproc_rmdir_2 __P((struct diropargs *da));
nfsstat *nfsproc_remove_2 __P((struct diropargs *da));
nfsstat *nfsproc_rename_2 __P((struct renameargs *ra));
nfsstat *nfsproc_symlink_2 __P((struct symlinkargs *sa));
struct readres *nfsproc_read_2 __P((struct readargs *ra));
struct attrstat *nfsproc_write_2 __P((struct writeargs *wa));
struct diropres *nfsproc_mkdir_2 __P((struct createargs *ca));
struct diropres *nfsproc_create_2 __P((struct createargs *ca));
struct diropres *nfsproc_lookup_2 __P((struct diropargs *da));
struct attrstat *nfsproc_getattr_2 __P((struct nfs_fh *fh));
struct attrstat *nfsproc_setattr_2 __P((struct sattrargs *sa));
struct statfsres *nfsproc_statfs_2 __P((struct nfs_fh *fh));
struct readdirres *nfsproc_readdir_2 __P((struct readdirargs *ra));
struct readlinkres *nfsproc_readlink_2 __P((struct nfs_fh *fh));
