ioLib.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:13k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* ioLib.h - I/O interface library header */
  2. /* Copyright 1984-2002 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 05j,03mar02,jkf  SPR#24332, added S_ioLib_CANT_OVERWRITE_DIR (12), orig by chn
  7. 05i,12dec01,jkf  SPR#72133, added FIOMOVE for usrFsLib mv() 
  8. 05h,21jun00,rsh  upgrade to dosFs 2.0
  9. 05i,03dec98,lrn  add FIOTRUNC64 (SPR#23692)
  10. 05h,15oct98,lrn  added 64-bit ioctl codes for dosFsLib and rawFsLib
  11. 05g,29aug95,hdn  added S_ioLib_UNFORMATED for floppy disk driver.
  12. 05f,29dec93,jmm  added FIOTIMESET for utime() support
  13.                  added FIOINODETONAME to translate inodes to names
  14.  added FIOFSTATFSGET to get information for fstatfs()
  15. 05e,02oct92,srh  added FIOGETFL ioctl code
  16. 05d,22sep92,rrr  added support for c++
  17. 05c,18sep92,smb  moved open and creat prototypes to fcntl.h.
  18. 05b,16sep92,kdl  added include of unistd.h; added L_* definitions for compat.
  19. 05a,02aug92,jcf  added creat().
  20. 04z,29jul92,smb  added include for fcntl.h. removed fopen options.
  21. 04y,22jul92,kdl  added include of stdio.h if using delete() macro.
  22. 04x,22jul92,kdl  removed references to delete(); added conditional macro
  23.  definition for delete() to use remove() instead.
  24. 04w,04jul92,jcf  cleaned up.
  25. 04v,30jun92,kdl  added FIONCONTIG and FIOTRUNC ioctl codes; added CONTIG_MAX.
  26. 04u,26may92,rrr  the tree shuffle
  27. 04t,05dec91,rrr  moved O_ and L_ macros to their posix header files
  28. 04s,26nov91,llk  fixed delete() prototype.
  29. 04r,04oct91,rrr  passed through the ansification filter
  30.   -fixed #else and #endif
  31.   -changed READ, WRITE and UPDATE to O_RDONLY O_WRONLY and
  32.    O_RDWR
  33.   -changed VOID to void
  34.   -changed copyright notice
  35. 04q,10jun91.del  added pragma for gnu960 alignment.
  36. 04p,23oct90,shl  changed ioctl()'s last parameter type from "int" to "void *".
  37. 04o,20oct90,dnw  removed "iosLib.h" and declaration that required it.
  38. 04n,19oct90,shl  added #include "iosLib.h".
  39. 04m,05oct90,dnw  deleted private routines.
  40.  added chdir(), getcwd(), remove(), rename()
  41. 04l,05oct90,shl  added ANSI function prototypes.
  42.                  made #endif ANSI style.
  43.                  added copyright notice.
  44. 04k,10aug90,dnw  added declaration of ioDefDirGet().
  45. 04j,11jul90,jcc  added FIOSCSICOMMAND.
  46. 04i,14jun90,kdl  added FIOUNMOUNT.
  47. 04h,25may90,dnw  added include of limits.h and defined MAX_FILENAME_LENGTH
  48.    in terms of PATH_MAX
  49. 04g,20apr90,kdl  added FIOREADDIR, FIOFSTATGET.
  50. 04f,01apr90,llk  added S_ioLib_NAME_TOO_LONG.
  51.  decreased MAX_DIRNAMES.
  52. 04e,17mar90,rdc  added FIOSELECT and FIOUNSELECT.
  53.     dab  changed O_CREAT and O_TRUNC values (from 0x80 and 0x100 to
  54.  001000 and 002000).  fixed spelling of S_ioLib_CANCELLED.
  55.     kdl  added MS-DOS functions: FIONFREE, FIOMKDIR, FIORMDIR,
  56.  FIOLABELGET, FIOLABELSET, FIOATTRIBSET, FIOCONTIG.
  57. 04d,27jul89,hjb  added ty protocol hook stuff: FIOPROTOHOOK,FIOPROTOARG
  58.    FIORBUFSET,FIOWBUFSET,FIORFLUSH,FIOWFLUSH.
  59. 04c,21apr89,dab  added FIOSYNC for sync to disk.
  60. 04b,18nov88,dnw  removed NOT_GENERIC stuff.
  61. 04a,22jun88,dnw  moved READ, WRITE, and UPDATE back to vxWorks.h.
  62. 03z,04jun88,llk  added MAX_DIRNAMES and S_ioLib_NO_DEVICE_NAME_IN_PATH for path
  63.    parsing.
  64.  added FSTAT for file types (inspired by nfs).
  65.  added DEFAULT_FILE_PERM and DEFAULT_DIR_PERM for newly created
  66.    files and directories.
  67. 03y,30apr88,gae  got read/write modes right.
  68. 03x,29mar88,gae  added FIOISATTY.  Added UNIX style open() and lseek() flags.
  69.  moved READ, WRITE, and UPDATE here from vxWorks.h.
  70. 03w,31dec87,jlf  added FOLLOW_LINK.
  71. 03v,01oct87,gae  added FIOGETNAME for all file descriptors.
  72.  added FIO[SG]ETOPTIONS for line options on devices.
  73. 03u,09sep87,dnw  added FIONBIO for sockets.
  74.  added FIONMSGS for pipes.
  75. 03t,09sep87,dnw  added FIOSQUEEZE and HD_1, HD_2 for rt-11 disks.
  76. 03s,09jun87,ecs  added S_ioLib_CANCELED & FIOCANCEL.
  77. 03r,14feb87,dnw  added S_ioLib_NO_FILENAME.
  78. 03q,04feb87,llk  added FIODISKCHANGE.
  79. 03p,24dec86,gae  changed stsLib.h to vwModNum.h.
  80. 03o,01dec86,dnw  increased MAX_FILENAME_LENGTH from 32 to 100.
  81. 03n,20nov86,dnw  added S_ioLib_DISK_NOT_PRESENT.
  82. 03m,17oct86,gae  added S_ioLib_WRITE_PROTECTED.
  83. 03l,21may86,llk  corrected comments.
  84. 03k,23mar86,jlf  changed GENERIC to NOT_GENERIC
  85. 03j,08mar86,dnw  added S_ioLib_DEVICE_TIMEOUT.
  86. */
  87. #ifndef __INCioLibh
  88. #define __INCioLibh
  89. #ifdef __cplusplus
  90. extern "C" {
  91. #endif
  92. #include "vwModNum.h"
  93. #include "limits.h"
  94. #include "net/uio.h"
  95. #include "fcntl.h"
  96. #include "unistd.h"
  97. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  98. #pragma align 1 /* tell gcc960 not to optimize alignments */
  99. #endif /* CPU_FAMILY==I960 */
  100. #define MAX_DIRNAMES 32 /* max directory names in path*/
  101. #define MAX_FILENAME_LENGTH (PATH_MAX + 1) /* max chars in filename
  102.  * including EOS*/
  103. /* I/O status codes */
  104. #define S_ioLib_NO_DRIVER (M_ioLib | 1)
  105. #define S_ioLib_UNKNOWN_REQUEST (M_ioLib | 2)
  106. #define S_ioLib_DEVICE_ERROR (M_ioLib | 3)
  107. #define S_ioLib_DEVICE_TIMEOUT (M_ioLib | 4)
  108. #define S_ioLib_WRITE_PROTECTED (M_ioLib | 5)
  109. #define S_ioLib_DISK_NOT_PRESENT (M_ioLib | 6)
  110. #define S_ioLib_NO_FILENAME (M_ioLib | 7)
  111. #define S_ioLib_CANCELLED (M_ioLib | 8)
  112. #define S_ioLib_NO_DEVICE_NAME_IN_PATH (M_ioLib | 9)
  113. #define S_ioLib_NAME_TOO_LONG (M_ioLib | 10)
  114. #define S_ioLib_UNFORMATED (M_ioLib | 11)
  115. #define S_ioLib_CANT_OVERWRITE_DIR      (M_ioLib | 12)
  116. /* ioctl function codes */
  117. #define FIONREAD 1 /* get num chars available to read */
  118. #define FIOFLUSH 2 /* flush any chars in buffers */
  119. #define FIOOPTIONS 3 /* set options (FIOSETOPTIONS) */
  120. #define FIOBAUDRATE 4 /* set serial baud rate */
  121. #define FIODISKFORMAT 5 /* format disk */
  122. #define FIODISKINIT 6 /* initialize disk directory */
  123. #define FIOSEEK 7 /* set current file char position */
  124. #define FIOWHERE 8 /* get current file char position */
  125. #define FIODIRENTRY 9 /* return a directory entry (obsolete)*/
  126. #define FIORENAME 10 /* rename a directory entry */
  127. #define FIOREADYCHANGE 11 /* return TRUE if there has been a
  128.    media change on the device */
  129. #define FIONWRITE 12 /* get num chars still to be written */
  130. #define FIODISKCHANGE 13 /* set a media change on the device */
  131. #define FIOCANCEL 14 /* cancel read or write on the device */
  132. #define FIOSQUEEZE 15 /* squeeze out empty holes in rt-11
  133.  * file system */
  134. #define FIONBIO 16 /* set non-blocking I/O; SOCKETS ONLY!*/
  135. #define FIONMSGS 17 /* return num msgs in pipe */
  136. #define FIOGETNAME 18 /* return file name in arg */
  137. #define FIOGETOPTIONS 19 /* get options */
  138. #define FIOSETOPTIONS FIOOPTIONS /* set options */
  139. #define FIOISATTY 20 /* is a tty */
  140. #define FIOSYNC 21 /* sync to disk */
  141. #define FIOPROTOHOOK 22 /* specify protocol hook routine */
  142. #define FIOPROTOARG 23 /* specify protocol argument */
  143. #define FIORBUFSET 24 /* alter the size of read buffer  */
  144. #define FIOWBUFSET 25 /* alter the size of write buffer */
  145. #define FIORFLUSH 26 /* flush any chars in read buffers */
  146. #define FIOWFLUSH 27 /* flush any chars in write buffers */
  147. #define FIOSELECT 28 /* wake up process in select on I/O */
  148. #define FIOUNSELECT 29 /* wake up process in select on I/O */
  149. #define FIONFREE        30              /* get free byte count on device */
  150. #define FIOMKDIR        31              /* create a directory */
  151. #define FIORMDIR        32              /* remove a directory */
  152. #define FIOLABELGET     33              /* get volume label */
  153. #define FIOLABELSET     34              /* set volume label */
  154. #define FIOATTRIBSET    35              /* set file attribute */
  155. #define FIOCONTIG       36              /* allocate contiguous space */
  156. #define FIOREADDIR      37              /* read a directory entry (POSIX) */
  157. #define FIOFSTATGET     38              /* get file status info */
  158. #define FIOUNMOUNT      39              /* unmount disk volume */
  159. #define FIOSCSICOMMAND  40              /* issue a SCSI command */
  160. #define FIONCONTIG      41              /* get size of max contig area on dev */
  161. #define FIOTRUNC        42              /* truncate file to specified length */
  162. #define FIOGETFL        43 /* get file mode, like fcntl(F_GETFL) */
  163. #define FIOTIMESET      44 /* change times on a file for utime() */
  164. #define FIOINODETONAME  45 /* given inode number, return filename*/
  165. #define FIOFSTATFSGET   46              /* get file system status info */
  166. #define FIOMOVE         47              /* move file, ala mv, (mv not rename) */
  167. /* 64-bit ioctl codes, "long long *" expected as 3rd argument */
  168. #define FIOCHKDSK (100  | 6400 ) /* salvage file system */
  169. #define FIOCONTIG64 (FIOCONTIG | 6400)
  170. #define FIONCONTIG64 (FIONCONTIG | 6400)
  171. #define FIONFREE64 (FIONFREE | 6400)
  172. #define FIONREAD64 (FIONREAD | 6400)
  173. #define FIOSEEK64 (FIOSEEK | 6400)
  174. #define FIOWHERE64 (FIOWHERE | 6400)
  175. #define FIOTRUNC64 (FIOTRUNC | 6400)
  176. /* TODO: need to consolidate ioctl codes from a few files to avoid collision */
  177. /* ioctl option values */
  178. #define OPT_ECHO 0x01 /* echo input */
  179. #define OPT_CRMOD 0x02 /* lf -> crlf */
  180. #define OPT_TANDEM 0x04 /* ^S/^Q flow control protocol */
  181. #define OPT_7_BIT 0x08 /* strip parity bit from 8 bit input */
  182. #define OPT_MON_TRAP 0x10 /* enable trap to monitor */
  183. #define OPT_ABORT 0x20 /* enable shell restart */
  184. #define OPT_LINE 0x40 /* enable basic line protocol */
  185. #define OPT_RAW 0 /* raw mode */
  186. #define OPT_TERMINAL (OPT_ECHO | OPT_CRMOD | OPT_TANDEM | 
  187.  OPT_MON_TRAP | OPT_7_BIT | OPT_ABORT | OPT_LINE)
  188. #define CONTIG_MAX -1 /* "count" for FIOCONTIG if requesting
  189.  *  maximum contiguous space on dev
  190.  */
  191. /* miscellaneous */
  192. #define FOLLOW_LINK -2 /* value for driver to return */
  193. #define DEFAULT_FILE_PERM 0000640 /* default file permissions
  194.    unix style rw-r----- */
  195. #define DEFAULT_DIR_PERM 0000750 /* default directory permissions
  196.    unix style rwxr-x--- */
  197. /* file types -- NOTE:  these values are specified in the NFS protocol spec */
  198. #define FSTAT_DIR 0040000 /* directory */
  199. #define FSTAT_CHR 0020000 /* character special file */
  200. #define FSTAT_BLK 0060000 /* block special file */
  201. #define FSTAT_REG 0100000 /* regular file */
  202. #define FSTAT_LNK 0120000 /* symbolic link file */
  203. #define FSTAT_NON 0140000 /* named socket */
  204. /* ioctl augmented arguments */
  205. /* the following is obsolete and only used now by rt-11 */
  206. typedef struct /* REQ_DIR_ENTRY */
  207.     {
  208.     int entryNum; /* number of directory entry */
  209.     char name[MAX_FILENAME_LENGTH]; /* name of file */
  210.     int nChars; /* number of chars in file */
  211.     short day; /* creation day of month */
  212.     short month; /* creation month of year */
  213.     short year; /* creation year of era */
  214.     } REQ_DIR_ENTRY;
  215. /* INODE_TO_NAME_IOCTL is used to call FIOINODETONAME */
  216.  
  217. typedef struct
  218.     {
  219.     ULONG  inode; /* file inode */
  220.     char * fileName; /* pointer to string to hold file name */
  221.     } INODE_TO_NAME_IOCTL;
  222.  
  223. /* disk formats */
  224. #define SS_1D_8 1 /* single side, single density, 8"     */
  225. #define SS_2D_8 2 /* single side, double density, 8"     */
  226. #define DS_1D_8 3 /* double side, single density, 8"     */
  227. #define DS_2D_8 4 /* double side, double density, 8"     */
  228. #define SS_1D_5 5 /* single side, single density, 5 1/4" */
  229. #define SS_2D_5 6 /* single side, double density, 5 1/4" */
  230. #define DS_1D_5 7 /* double side, single density, 5 1/4" */
  231. #define DS_2D_5 8 /* double side, double density, 5 1/4" */
  232. #define HD_1 129 /* hard disk - type 1 */
  233. #define HD_2 130 /* hard disk - type 2 */
  234. /* globals */
  235. extern int ioMaxLinkLevels; /* max number of symbolic links to traverse */
  236.  
  237. /* function declarations */
  238. #if defined(__STDC__) || defined(__cplusplus)
  239. #if 0
  240. extern STATUS  ioFullFileNameGet (char *pathName, DEV_HDR **ppDevHdr,
  241.    char *fullFileName);
  242. #else
  243. extern STATUS  ioFullFileNameGet ();
  244. #endif
  245. extern STATUS  ioDefPathCat (char *name);
  246. extern STATUS  ioDefPathSet (char *name);
  247. extern char * getwd (char *pathname);
  248. extern int  ioGlobalStdGet (int stdFd);
  249. extern int  ioTaskStdGet (int taskId, int stdFd);
  250. extern int  ioctl (int fd, int function, int arg);
  251. extern int      readv (int fd, struct iovec *iov, int iovcnt);
  252. extern void  ioDefDevGet (char *devName);
  253. extern void  ioDefDirGet (char *dirName);
  254. extern void  ioDefPathGet (char *pathname);
  255. extern void  ioGlobalStdSet (int stdFd, int newFd);
  256. extern void  ioTaskStdSet (int taskId, int stdFd, int newFd);
  257. extern int      writev (int fd, struct iovec *iov, int iovcnt);
  258. #else /* __STDC__ */
  259. extern STATUS  ioDefPathCat ();
  260. extern STATUS  ioDefPathSet ();
  261. extern STATUS  ioFullFileNameGet ();
  262. extern char * getwd ();
  263. extern int  ioGlobalStdGet ();
  264. extern int  ioTaskStdGet ();
  265. extern int  ioctl ();
  266. extern int readv ();
  267. extern void  ioDefDevGet ();
  268. extern void  ioDefDirGet ();
  269. extern void  ioDefPathGet ();
  270. extern void  ioGlobalStdSet ();
  271. extern void  ioTaskStdSet ();
  272. extern int writev ();
  273. #endif /* __STDC__ */
  274. /* Conditional definition of delete() for compatibility with earlier VxWorks */
  275. #define __DELETE_FUNC  FALSE  /* change to TRUE to use delete() */
  276. #if  __DELETE_FUNC
  277. #include "stdio.h"
  278. #define delete(filename)  remove(filename)
  279. #endif  /* __DELETE_FUNC */
  280. /* Miscellaneous obsolete definitions, for backward compatibility */
  281. #define L_SET SEEK_SET /* see unistd.h */
  282. #define L_INCR SEEK_CUR
  283. #define L_XTND SEEK_END
  284. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  285. #pragma align 0 /* turn off alignment requirement */
  286. #endif /* CPU_FAMILY==I960 */
  287. #ifdef __cplusplus
  288. }
  289. #endif
  290. #endif /* __INCioLibh */