/*  Constants defined by the NFS protocol

    ©1999 Joseph Walton

    This software is distributed under the terms of the GNU General Public
    License; either version 2 of the License, or (at your option) any
    later version.
*/

#ifndef NFSD_NFS_PROT_H
#define NFSD_NFS_PROT_H

#define NFS_PORT 2049

#define NFS_PROGRAM 100003
#define NFS_VERSION 2

#define NFS_FHSIZE 32

#define NFS_MAXDATA 8192
#define NFS_MAXPATHLEN 1024
#define NFS_MAXNAMELEN 255
#define NFS_COOKIESIZE 4

/*
 * Error status
 */
enum nfsstat {
        NFS_OK = 0,               /* no error */
        NFSERR_PERM = 1,          /* Not owner */
        NFSERR_NOENT = 2,         /* No such file or directory */
        NFSERR_IO = 5,            /* I/O error */
        NFSERR_NXIO = 6,          /* No such device or address */
        NFSERR_ACCES = 13,        /* Permission denied */
        NFSERR_EXIST = 17,        /* File exists */
        NFSERR_NODEV = 19,        /* No such device */
        NFSERR_NOTDIR = 20,       /* Not a directory*/
        NFSERR_ISDIR = 21,        /* Is a directory */
        NFSERR_INVAL = 22,        /* invalid argument */
        NFSERR_FBIG = 27,         /* File too large */
        NFSERR_NOSPC = 28,        /* No space left on device */
        NFSERR_ROFS = 30,         /* Read-only file system */
        NFSERR_NAMETOOLONG = 63,  /* File name too long */
        NFSERR_NOTEMPTY = 66,     /* Directory not empty */
        NFSERR_DQUOT = 69,        /* Disc quota exceeded */
        NFSERR_STALE = 70,        /* Stale NFS file handle */
        NFSERR_WFLUSH = 99        /* write cache flushed */
};

typedef enum nfsstat nfsstat;

/*
 * File types
 */
enum ftype {
        NFNON = 0,      /* non-file */
        NFREG = 1,      /* regular file */
        NFDIR = 2,      /* directory */
        NFBLK = 3,      /* block special */
        NFCHR = 4,      /* character special */
        NFLNK = 5,      /* symbolic link */
        NFSOCK = 6,     /* unix domain sockets */
        NFBAD = 7,      /* unused */
        NFFIFO = 8      /* named pipe */
};

typedef enum ftype ftype;

/*
 * File types
 */
#define NFSMODE_DIR 0040000   /* directory */
#define NFSMODE_REG 0100000   /* regular */
#define NFSMODE_LNK 0120000   /* symbolic link */

/* Procedure IDs */
#define NFS_PROC_NULL 0
#define NFS_PROC_GETATTR 1
#define NFS_PROC_SETATTR 2
#define NFS_PROC_ROOT 3
#define NFS_PROC_LOOKUP 4
#define NFS_PROC_READLINK 5
#define NFS_PROC_READ 6
#define NFS_PROC_WRITECACHE 7
#define NFS_PROC_WRITE 8
#define NFS_PROC_CREATE 9
#define NFS_PROC_REMOVE 10
#define NFS_PROC_RENAME 11
#define NFS_PROC_LINK 12
#define NFS_PROC_SYMLINK 13
#define NFS_PROC_MKDIR 14
#define NFS_PROC_RMDIR 15
#define NFS_PROC_READDIR 16
#define NFS_PROC_STATFS 17

#endif

