--- MiNT/src/file.h 2018/04/24 17:55:53 1.1.1.2 +++ MiNT/src/file.h 2018/04/24 17:58:54 1.1.1.6 @@ -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 { @@ -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; @@ -104,9 +114,9 @@ typedef struct xattr { #define S_IFREG 0100000 /* regular file */ -#define S_IFIFO 0120000 /* FIFO */ +#define S_IFIFO 0120000 /* FIFO */ -#define S_IMEM 0140000 /* memory region or process */ +#define S_IFMEM 0140000 /* memory region or process */ #define S_IFLNK 0160000 /* symbolic link */ @@ -150,7 +160,7 @@ typedef struct xattr { ushort dev; - ushort reserved1; + ushort rdev; /* "real" device */ ushort nlink; @@ -274,7 +284,23 @@ typedef struct devdrv { long ARGS_ON_STACK (*select) P_((FILEPTR *f, long proc, int mode)); - void ARGS_ON_STACK (*unselect) P_((FILEPTR *f, long proc, int mode)); + void ARGS_ON_STACK (*unselect) P_((FILEPTR *f, long proc, int mode)); + +/* extensions, check dev_descr.drvsize (size of DEVDRV struct) before calling: + + * fast RAW tty byte io */ + + long ARGS_ON_STACK (*writeb) P_((FILEPTR *f, const char *buf, long bytes)); + + long ARGS_ON_STACK (*readb) P_((FILEPTR *f, char *buf, long bytes)); + +/* what about: scatter/gather io for DMA devices... + + * long ARGS_ON_STACK (*writev) P_((FILEPTR *f, const struct iovec *iov, long cnt)); + + * long ARGS_ON_STACK (*readv) P_((FILEPTR *f, const struct iovec *iov, long cnt)); + + */ } DEVDRV; @@ -292,7 +318,9 @@ 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 ARGS_ON_STACK (*root) P_((int drv, fcookie *fc)); @@ -318,7 +346,9 @@ typedef struct filesys { long ARGS_ON_STACK (*remove) P_((fcookie *dir, const char *name)); - long ARGS_ON_STACK (*getname) P_((fcookie *relto, fcookie *dir, char *pathname)); + long ARGS_ON_STACK (*getname) P_((fcookie *relto, fcookie *dir, + + char *pathname, int size)); long ARGS_ON_STACK (*rename) P_((fcookie *olddir, char *oldname, @@ -352,7 +382,9 @@ typedef struct filesys { 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; @@ -402,7 +434,7 @@ struct kerinfo { void ARGS_ON_STACK (*alert) P_((const char *, ...)); - EXITING void ARGS_ON_STACK (*fatal) P_((const char *, ...)); + EXITING void ARGS_ON_STACK (*fatal) P_((const char *, ...)) NORETURN; @@ -450,7 +482,7 @@ struct kerinfo { void ARGS_ON_STACK (*nap) P_((unsigned)); - void ARGS_ON_STACK (*sleep) P_((int que, long cond)); + int ARGS_ON_STACK (*sleep) P_((int que, long cond)); void ARGS_ON_STACK (*wake) P_((int que, long cond)); @@ -462,13 +494,33 @@ struct kerinfo { int ARGS_ON_STACK (*denyshare) P_((FILEPTR *, FILEPTR *)); + LOCK * ARGS_ON_STACK (*denylock) P_((LOCK *, LOCK *)); -/* reserved for future use */ - LOCK * ARGS_ON_STACK (*denylock) P_((LOCK *, LOCK *)); +/* functions for adding/cancelling timeouts */ + + struct timeout * ARGS_ON_STACK (*addtimeout) P_((long, void (*)())); + + void ARGS_ON_STACK (*canceltimeout) P_((struct timeout *)); - long res2[9]; + struct timeout * ARGS_ON_STACK (*addroottimeout) P_((long, void (*)(), short)); + + void ARGS_ON_STACK (*cancelroottimeout) P_((struct timeout *)); + + + +/* miscellaneous other things */ + + long ARGS_ON_STACK (*ikill) P_((int, int)); + + void ARGS_ON_STACK (*iwake) P_((int que, long cond, short pid)); + + + +/* reserved for future use */ + + long res2[3]; }; @@ -588,7 +640,57 @@ struct kerinfo { # define DP_CASEINSENS 2 /* case insensitive, preserved */ -#define DP_MAXREQ 6 /* highest legal request */ +#define DP_MODEATTR 7 + +# define DP_ATTRBITS 0x000000ffL /* mask for valid TOS attribs */ + +# define DP_MODEBITS 0x000fff00L /* mask for valid Unix file modes */ + +# define DP_FILETYPS 0xfff00000L /* mask for valid file types */ + +# define DP_FT_DIR 0x00100000L /* directories (always if . is there) */ + +# define DP_FT_CHR 0x00200000L /* character special files */ + +# define DP_FT_BLK 0x00400000L /* block special files, currently unused */ + +# define DP_FT_REG 0x00800000L /* regular files */ + +# define DP_FT_LNK 0x01000000L /* symbolic links */ + +# define DP_FT_SOCK 0x02000000L /* sockets, currently unused */ + +# define DP_FT_FIFO 0x04000000L /* pipes */ + +# define DP_FT_MEM 0x08000000L /* shared memory or proc files */ + +#define DP_XATTRFIELDS 8 + +# define DP_INDEX 0x0001 + +# define DP_DEV 0x0002 + +# define DP_RDEV 0x0004 + +# define DP_NLINK 0x0008 + +# define DP_UID 0x0010 + +# define DP_GID 0x0020 + +# define DP_BLKSIZE 0x0040 + +# define DP_SIZE 0x0080 + +# define DP_NBLOCKS 0x0100 + +# define DP_ATIME 0x0200 + +# define DP_CTIME 0x0400 + +# define DP_MTIME 0x0800 + +#define DP_MAXREQ 8 /* highest legal request */ @@ -654,11 +756,11 @@ struct kerinfo { #define FIONWRITE (('F'<< 8) | 2) -#define TIOCGETP (('T'<< 8) | 0) +#define FIOEXCEPT (('F'<< 8) | 5) -#define TIOCSETP (('T'<< 8) | 1) +#define TIOCGETP (('T'<< 8) | 0) -#define TIOCSETN TIOCSETP +#define TIOCSETN (('T'<< 8) | 1) #define TIOCGETC (('T'<< 8) | 2) @@ -698,6 +800,28 @@ struct kerinfo { #define TIOCSFLAGS (('T'<< 8) | 23) +#define TIOCOUTQ (('T'<< 8) | 24) + +#define TIOCSETP (('T'<< 8) | 25) + +#define TIOCHPCL (('T'<< 8) | 26) + +#define TIOCCAR (('T'<< 8) | 27) + +#define TIOCNCAR (('T'<< 8) | 28) + +#define TIOCWONLINE (('T'<< 8) | 29) + +#define TIOCSFLAGSB (('T'<< 8) | 30) + +#define TIOCGSTATE (('T'<< 8) | 31) + +#define TIOCSSTATEB (('T'<< 8) | 32) + +#define TIOCGVMIN (('T'<< 8) | 33) + +#define TIOCSVMIN (('T'<< 8) | 34) + /* cursor control Fcntls: @@ -758,6 +882,26 @@ struct kerinfo { #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) @@ -794,7 +938,11 @@ struct kerinfo { cursor keys, etc. */ -/* 0x0400 and 0x0800 still available */ +#define T_ECHOCTL 0x0400 /* echo ctl chars as ^x */ + +/* 0x0800 still available */ + + #define T_TANDEM 0x1000 @@ -812,6 +960,16 @@ struct kerinfo { /* some flags for TIOC[GS]FLAGS */ +#define TF_CAR 0x800 /* nonlocal mode, require carrier */ + +#define TF_NLOCAL TF_CAR + + + +#define TF_BRKINT 0x80 /* allow breaks interrupt (like ^C) */ + + + #define TF_STOPBITS 0x0003 #define TF_1STOP 0x0001 @@ -844,8 +1002,14 @@ struct kerinfo { #define TS_ESC 0x00ff +#define TS_BLIND 0x800 /* tty is `blind' i.e. has no carrier + + (cleared in local mode) */ + #define TS_HOLD 0x1000 /* hold (e.g. ^S/^Q) */ +#define TS_HPCL 0x4000 /* hang up on close */ + #define TS_COOKED 0x8000 /* interpret control chars */ @@ -936,7 +1100,9 @@ struct tty { short use_cnt; /* number of times terminal is open */ - short res1; /* reserved for future expansion */ + short aux_cnt; /* number of times terminal is open as + + /dev/aux */ struct sgttyb sg; @@ -952,7 +1118,43 @@ struct tty { char *xkey; /* extended keyboard table */ - long resrvd[3]; /* for future expansion */ + long hup_ospeed; /* saved ospeed while hanging up */ + + unsigned short vmin, vtime; /* min chars, timeout for RAW reads */ + + long resrvd[1]; /* for future expansion */ + +}; + + + +struct bios_tty { + + IOREC_T *irec; /* From XBIOS ... */ + + long *rsel; /* pointer to field in tty struct */ + + IOREC_T *orec; /* Same, for output... */ + + long *wsel; + + long ispeed, ospeed; /* last speeds set */ + + long *baudmap, maxbaud; /* Rsconf baud word <-> bps table */ + + short *baudx; + + struct tty *tty; + + long bticks; /* when to take a break for real */ + + long vticks; /* ..check read buf next (vmin/speed) */ + + char clocal, brkint; /* flags: local mode, break == ^C */ + + short tosfd; /* if != EUNDEV: fd to pass Fcntl()s */ + + short bdev, unused1; }; @@ -978,7 +1180,39 @@ struct dev_descr { struct tty *tty; - long reserved[4]; + long drvsize; /* size of DEVDRV struct */ + + long reserved[3]; + +}; + + + + + +#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]; }; @@ -1012,7 +1246,19 @@ struct dev_descr { -#define PROC_BASE_DEV 0xA000 +/* various fields for the "rdev" device numbers */ + +#define BIOS_DRIVE_RDEV 0x0000 + +#define BIOS_RDEV 0x0100 + +#define FAKE_RDEV 0x0200 + +#define PIPE_RDEV 0x7e00 + +#define UNK_RDEV 0x7f00 + +#define PROC_RDEV_BASE 0xa000 @@ -1026,11 +1272,43 @@ extern FILESYS *drives[NUM_DRIVES]; extern struct tty default_tty; -extern char follow_links[]; +#define follow_links ((char *)-1L) #endif +/* internal bios file structure */ + + + +#define BNAME_MAX 13 + + + +struct bios_file { + + char name[BNAME_MAX+1]; /* device name */ + + DEVDRV *device; /* device driver for device */ + + short private; /* extra info for device driver */ + + ushort flags; /* flags for device open */ + + struct tty *tty; /* tty structure (if appropriate) */ + + struct bios_file *next; + + short lockpid; /* owner of the lock */ + + XATTR xattr; /* guess what... */ + + long drvsize; /* size of DEVDRV struct */ + +}; + + + #endif /* _filesys_h */