--- MiNT/src/file.h 2018/04/24 17:55:36 1.1 +++ MiNT/src/file.h 2018/04/24 17:58:10 1.1.1.5 @@ -1,6 +1,10 @@ /* -Copyright 1991,1992 Eric R. Smith. All rights reserved. +Copyright 1991,1992 Eric R. Smith. + +Copyright 1992,1993,1994 Atari Corporation. + +All rights reserved. */ @@ -16,6 +20,8 @@ struct filesys; /* forward declaration struct devdrv; /* ditto */ +struct timeout; /* and ditto */ + typedef struct f_cookie { @@ -42,9 +48,9 @@ typedef struct dtabuf { long magic; -#define SVALID 0x1234fedc /* magic for a valid search */ +#define SVALID 0x1234fedcL /* magic for a valid search */ -#define EVALID 0x5678ba90 /* magic for an exhausted search */ +#define EVALID 0x5678ba90L /* magic for an exhausted search */ @@ -62,7 +68,7 @@ typedef struct dtabuf { long dta_size; - char dta_name[TOS_NAMELEN]; + char dta_name[TOS_NAMELEN+1]; } DTABUF; @@ -84,6 +90,10 @@ typedef struct dirstruct { /* NOTE: this must be at least 45 bytes */ + struct dirstruct *next; /* linked together so we can close them + + on process termination */ + } DIR; @@ -150,7 +160,7 @@ typedef struct xattr { ushort dev; - ushort reserved1; + ushort rdev; /* "real" device */ ushort nlink; @@ -258,23 +268,23 @@ typedef struct ilock { typedef struct devdrv { - long (*open) P_((FILEPTR *f)); + long ARGS_ON_STACK (*open) P_((FILEPTR *f)); - long (*write) P_((FILEPTR *f, const char *buf, long bytes)); + long ARGS_ON_STACK (*write) P_((FILEPTR *f, const char *buf, long bytes)); - long (*read) P_((FILEPTR *f, char *buf, long bytes)); + long ARGS_ON_STACK (*read) P_((FILEPTR *f, char *buf, long bytes)); - long (*lseek) P_((FILEPTR *f, long where, int whence)); + long ARGS_ON_STACK (*lseek) P_((FILEPTR *f, long where, int whence)); - long (*ioctl) P_((FILEPTR *f, int mode, void *buf)); + long ARGS_ON_STACK (*ioctl) P_((FILEPTR *f, int mode, void *buf)); - long (*datime) P_((FILEPTR *f, short *timeptr, int rwflag)); + long ARGS_ON_STACK (*datime) P_((FILEPTR *f, short *timeptr, int rwflag)); - long (*close) P_((FILEPTR *f, int pid)); + long ARGS_ON_STACK (*close) P_((FILEPTR *f, int pid)); - long (*select) P_((FILEPTR *f, long proc, int mode)); + long ARGS_ON_STACK (*select) P_((FILEPTR *f, long proc, int mode)); - void (*unselect) P_((FILEPTR *f, long proc, int mode)); + void ARGS_ON_STACK (*unselect) P_((FILEPTR *f, long proc, int mode)); } DEVDRV; @@ -292,67 +302,73 @@ typedef struct filesys { #define FS_NOXBIT 0x04 /* if a file can be read, it can be executed */ +#define FS_LONGPATH 0x08 /* file system understands "size" argument to + "getname" */ - long (*root) P_((int drv, fcookie *fc)); + long ARGS_ON_STACK (*root) P_((int drv, fcookie *fc)); - long (*lookup) P_((fcookie *dir, const char *name, fcookie *fc)); + long ARGS_ON_STACK (*lookup) P_((fcookie *dir, const char *name, fcookie *fc)); - long (*creat) P_((fcookie *dir, const char *name, unsigned mode, + long ARGS_ON_STACK (*creat) P_((fcookie *dir, const char *name, unsigned mode, int attrib, fcookie *fc)); - DEVDRV *(*getdev) P_((fcookie *fc, long *devspecial)); + DEVDRV * ARGS_ON_STACK (*getdev) P_((fcookie *fc, long *devspecial)); + + long ARGS_ON_STACK (*getxattr) P_((fcookie *file, XATTR *xattr)); - long (*getxattr) P_((fcookie *file, XATTR *xattr)); + long ARGS_ON_STACK (*chattr) P_((fcookie *file, int attr)); - long (*chattr) P_((fcookie *file, int attr)); + long ARGS_ON_STACK (*chown) P_((fcookie *file, int uid, int gid)); - long (*chown) P_((fcookie *file, int uid, int gid)); + long ARGS_ON_STACK (*chmode) P_((fcookie *file, unsigned mode)); - long (*chmode) P_((fcookie *file, unsigned mode)); + long ARGS_ON_STACK (*mkdir) P_((fcookie *dir, const char *name, unsigned mode)); - long (*mkdir) P_((fcookie *dir, const char *name, unsigned mode)); + long ARGS_ON_STACK (*rmdir) P_((fcookie *dir, const char *name)); - long (*rmdir) P_((fcookie *dir, const char *name)); + long ARGS_ON_STACK (*remove) P_((fcookie *dir, const char *name)); - long (*remove) P_((fcookie *dir, const char *name)); + long ARGS_ON_STACK (*getname) P_((fcookie *relto, fcookie *dir, - long (*getname) P_((fcookie *relto, fcookie *dir, char *pathname)); + char *pathname, int size)); - long (*rename) P_((fcookie *olddir, char *oldname, + long ARGS_ON_STACK (*rename) P_((fcookie *olddir, char *oldname, fcookie *newdir, const char *newname)); - long (*opendir) P_((DIR *dirh, int tosflag)); + long ARGS_ON_STACK (*opendir) P_((DIR *dirh, int tosflag)); - long (*readdir) P_((DIR *dirh, char *name, int namelen, fcookie *fc)); + long ARGS_ON_STACK (*readdir) P_((DIR *dirh, char *name, int namelen, fcookie *fc)); - long (*rewinddir) P_((DIR *dirh)); + long ARGS_ON_STACK (*rewinddir) P_((DIR *dirh)); - long (*closedir) P_((DIR *dirh)); + long ARGS_ON_STACK (*closedir) P_((DIR *dirh)); - long (*pathconf) P_((fcookie *dir, int which)); + long ARGS_ON_STACK (*pathconf) P_((fcookie *dir, int which)); - long (*dfree) P_((fcookie *dir, long *buf)); + long ARGS_ON_STACK (*dfree) P_((fcookie *dir, long *buf)); - long (*writelabel) P_((fcookie *dir, const char *name)); + long ARGS_ON_STACK (*writelabel) P_((fcookie *dir, const char *name)); - long (*readlabel) P_((fcookie *dir, char *name, int namelen)); + long ARGS_ON_STACK (*readlabel) P_((fcookie *dir, char *name, int namelen)); - long (*symlink) P_((fcookie *dir, const char *name, const char *to)); + long ARGS_ON_STACK (*symlink) P_((fcookie *dir, const char *name, const char *to)); - long (*readlink) P_((fcookie *dir, char *buf, int len)); + long ARGS_ON_STACK (*readlink) P_((fcookie *dir, char *buf, int len)); - long (*hardlink) P_((fcookie *fromdir, const char *fromname, + long ARGS_ON_STACK (*hardlink) P_((fcookie *fromdir, const char *fromname, fcookie *todir, const char *toname)); - long (*fscntl) P_((fcookie *dir, const char *name, int cmd, long arg)); + long ARGS_ON_STACK (*fscntl) P_((fcookie *dir, const char *name, int cmd, long arg)); - long (*dskchng) P_((int drv)); + long ARGS_ON_STACK (*dskchng) P_((int drv)); - long zero; + long ARGS_ON_STACK (*release) P_((fcookie *)); + + long ARGS_ON_STACK (*dupcookie) P_((fcookie *new, fcookie *old)); } FILESYS; @@ -390,55 +406,55 @@ struct kerinfo { /* media change vector */ - void (*drvchng) P_((unsigned)); + void ARGS_ON_STACK (*drvchng) P_((unsigned)); /* Debugging stuff */ - void (*trace) P_((const char *, ...)); + void ARGS_ON_STACK (*trace) P_((const char *, ...)); - void (*debug) P_((const char *, ...)); + void ARGS_ON_STACK (*debug) P_((const char *, ...)); - void (*alert) P_((const char *, ...)); + void ARGS_ON_STACK (*alert) P_((const char *, ...)); - EXITING void (*fatal) P_((const char *, ...)); + EXITING void ARGS_ON_STACK (*fatal) P_((const char *, ...)); /* memory allocation functions */ - void * (*kmalloc) P_((long)); + void * ARGS_ON_STACK (*kmalloc) P_((long)); - void (*kfree) P_((void *)); + void ARGS_ON_STACK (*kfree) P_((void *)); - void * (*umalloc) P_((long)); + void * ARGS_ON_STACK (*umalloc) P_((long)); - void (*ufree) P_((void *)); + void ARGS_ON_STACK (*ufree) P_((void *)); /* utility functions for string manipulation */ - int (*strnicmp) P_((const char *, const char *, int)); + int ARGS_ON_STACK (*strnicmp) P_((const char *, const char *, int)); - int (*stricmp) P_((const char *, const char *)); + int ARGS_ON_STACK (*stricmp) P_((const char *, const char *)); - char * (*strlwr) P_((char *)); + char * ARGS_ON_STACK (*strlwr) P_((char *)); - char * (*strupr) P_((char *)); + char * ARGS_ON_STACK (*strupr) P_((char *)); - int (*sprintf) P_((char *, const char *, ...)); + int ARGS_ON_STACK (*sprintf) P_((char *, const char *, ...)); /* utility functions for manipulating time */ - void (*millis_time) P_((unsigned long, short *)); + void ARGS_ON_STACK (*millis_time) P_((unsigned long, short *)); - long (*unixtim) P_((unsigned, unsigned)); + long ARGS_ON_STACK (*unixtim) P_((unsigned, unsigned)); - long (*dostim) P_((long)); + long ARGS_ON_STACK (*dostim) P_((long)); @@ -448,27 +464,35 @@ struct kerinfo { */ - void (*nap) P_((unsigned)); + void ARGS_ON_STACK (*nap) P_((unsigned)); - void (*sleep) P_((int que, long cond)); + int ARGS_ON_STACK (*sleep) P_((int que, long cond)); - void (*wake) P_((int que, long cond)); + void ARGS_ON_STACK (*wake) P_((int que, long cond)); - void (*wakeselect) P_((long param)); + void ARGS_ON_STACK (*wakeselect) P_((long param)); /* file system utility functions */ - int (*denyshare) P_((FILEPTR *, FILEPTR *)); + int ARGS_ON_STACK (*denyshare) P_((FILEPTR *, FILEPTR *)); + LOCK * ARGS_ON_STACK (*denylock) P_((LOCK *, LOCK *)); -/* reserved for future use */ - LOCK * (*denylock) P_((LOCK *, LOCK *)); +/* functions for adding/cancelling timeouts */ - long res2[9]; + struct timeout * ARGS_ON_STACK (*addtimeout) P_((long, void (*)())); + + void ARGS_ON_STACK (*canceltimeout) P_((struct timeout *)); + + + +/* reserved for future use */ + + long res2[7]; }; @@ -642,6 +666,8 @@ struct kerinfo { #define F_SETLK 6 +#define F_SETLKW 7 + /* more constants for various Fcntl's */ @@ -696,8 +722,32 @@ struct kerinfo { #define TIOCSFLAGS (('T'<< 8) | 23) +#define TIOCOUTQ (('T'<< 8) | 24) + +/* cursor control Fcntls: + + * NOTE THAT THESE MUST BE TOGETHER + + */ + +#define TCURSOFF (('c'<< 8) | 0) + +#define TCURSON (('c'<< 8) | 1) + +#define TCURSBLINK (('c'<< 8) | 2) + +#define TCURSSTEADY (('c'<< 8) | 3) + +#define TCURSSRATE (('c'<< 8) | 4) + +#define TCURSGRATE (('c'<< 8) | 5) + + + +/* process stuff */ + #define PPROCADDR (('P'<< 8) | 1) #define PBASEADDR (('P'<< 8) | 2) @@ -708,6 +758,52 @@ struct kerinfo { #define PGETFLAGS (('P'<< 8) | 5) +#define PTRACESFLAGS (('P'<< 8) | 6) + +#define PTRACEGFLAGS (('P'<< 8) | 7) + +# define P_ENABLE (1 << 0) /* enable tracing */ + +#ifdef NOTYETDEFINED + +# define P_DOS (1 << 1) /* trace DOS calls - unimplemented */ + +# define P_BIOS (1 << 2) /* trace BIOS calls - unimplemented */ + +# define P_XBIOS (1 << 3) /* trace XBIOS calls - unimplemented */ + +#endif + + + +#define PTRACEGO (('P'<< 8) | 8) /* these 4 must be together */ + +#define PTRACEFLOW (('P'<< 8) | 9) + +#define PTRACESTEP (('P'<< 8) | 10) + +#define PTRACE11 (('P'<< 8) | 11) + +#define PLOADINFO (('P'<< 8) | 12) + +#define PFSTAT (('P'<< 8) | 13) + + + +struct ploadinfo { + + /* passed */ + + short fnamelen; + + /* returned */ + + char *cmdlin, *fname; + +}; + + + #define SHMGETBLK (('M'<< 8) | 0) @@ -934,40 +1030,124 @@ struct dev_descr { -/* external variables */ +#define FS_INSTALL 0xf001 /* let the kernel know about the file system */ + +#define FS_MOUNT 0xf002 /* make a new directory for a file system */ + +#define FS_UNMOUNT 0xf003 /* remove a directory for a file system */ + +#define FS_UNINSTALL 0xf004 /* remove a file system from the list */ + + + + + +struct fs_descr + +{ + + FILESYS *file_system; + + short dev_no; /* this is filled in by MiNT if arg == FS_MOUNT*/ + + long flags; + + long reserved[4]; + +}; + + + + + +/* number of BIOS drives */ #define NUM_DRIVES 32 -extern FILESYS *drives[NUM_DRIVES]; +#define BIOSDRV (NUM_DRIVES) + +#define PIPEDRV (NUM_DRIVES+1) -#define BIOSDRV ('V'-'A') +#define PROCDRV (NUM_DRIVES+2) -#define PIPEDRV ('Q'-'A') +#define SHMDRV (NUM_DRIVES+3) -#define PROCDRV ('X'-'A') + + +#define UNI_NUM_DRVS (NUM_DRIVES+4) #define UNIDRV ('U'-'A') -#define PSEUDODRVS ((1L<