?? fileio.h
字號:
_name, \ _fsname, \ _devname, \ _data, \ false, \ NULL, \ CYG_DIR_NULL \};//=============================================================================// IO vector descriptorsstruct CYG_IOVEC_TAG{ void *iov_base; /* Base address. */ ssize_t iov_len; /* Length. */};enum cyg_uio_rw { UIO_READ, UIO_WRITE };/* Segment flag values. */enum cyg_uio_seg{ UIO_USERSPACE, /* from user data space */ UIO_SYSSPACE /* from system space */};struct CYG_UIO_TAG{ struct CYG_IOVEC_TAG *uio_iov; /* pointer to array of iovecs */ int uio_iovcnt; /* number of iovecs in array */ off_t uio_offset; /* offset into file this uio corresponds to */ ssize_t uio_resid; /* residual i/o count */ enum cyg_uio_seg uio_segflg; /* see above */ enum cyg_uio_rw uio_rw; /* see above */};// Limits#define UIO_SMALLIOV 8 /* 8 on stack, else malloc *///=============================================================================// Description of open filetypedef int cyg_fileop_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio,unsigned int *uiType);//typedef cyg_fileop_readwrite cyg_fileop_read;
typedef int cyg_fileop_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);//typedef cyg_fileop_readwrite cyg_fileop_write;typedef int cyg_fileop_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence );typedef int cyg_fileop_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com, CYG_ADDRWORD data);typedef cyg_bool cyg_fileop_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info);typedef int cyg_fileop_fsync (struct CYG_FILE_TAG *fp, int mode ); typedef int cyg_fileop_close (struct CYG_FILE_TAG *fp);typedef int cyg_fileop_fstat (struct CYG_FILE_TAG *fp, struct stat *buf );typedef int cyg_fileop_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len );typedef int cyg_fileop_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len );struct CYG_FILEOPS_TAG{ cyg_fileop_read *fo_read; cyg_fileop_write *fo_write; cyg_fileop_lseek *fo_lseek; cyg_fileop_ioctl *fo_ioctl; cyg_fileop_select *fo_select; cyg_fileop_fsync *fo_fsync; cyg_fileop_close *fo_close; cyg_fileop_fstat *fo_fstat; cyg_fileop_getinfo *fo_getinfo; cyg_fileop_setinfo *fo_setinfo;};//以下這個結構就是一個file結構struct CYG_FILE_TAG{ cyg_uint32 f_flag; /* file state */ cyg_uint16 f_ucount; /* use count */ cyg_uint16 f_type; /* descriptor type */ cyg_uint32 f_syncmode; /* synchronization protocol */ struct CYG_FILEOPS_TAG *f_ops; /* file operations */ off_t f_offset; /* current offset */ CYG_ADDRWORD f_data; /* file or socket */ CYG_ADDRWORD f_xops; /* extra type specific ops */ cyg_mtab_entry *f_mte; /* mount table entry */};//-----------------------------------------------------------------------------// File flags// Allocation here is that bits 0..15 are copies of bits from the open// flags, bits 16..23 are extra bits that are visible to filesystems but// are not derived from the open call, and bits 24..31 are reserved for// the fileio infrastructure.#define CYG_FREAD O_RDONLY#define CYG_FWRITE O_WRONLY#define CYG_FNONBLOCK O_NONBLOCK#define CYG_FAPPEND O_APPEND#define CYG_FASYNC 0x00010000#define CYG_FDIR 0x00020000#define CYG_FLOCKED 0x01000000 // Set if file is locked#define CYG_FLOCK 0x02000000 // Lock during file ops#define CYG_FALLOC 0x80000000 // File is "busy", i.e. allocated// Mask for open mode bits stored in file object#define CYG_FILE_MODE_MASK (CYG_FREAD|CYG_FWRITE|CYG_FNONBLOCK|CYG_FAPPEND)//-----------------------------------------------------------------------------// Type of file#define CYG_FILE_TYPE_FILE 1 /* file */#define CYG_FILE_TYPE_SOCKET 2 /* communications endpoint */#define CYG_FILE_TYPE_DEVICE 3 /* device *///-----------------------------------------------------------------------------// Keys for getinf() and setinfo()#define FILE_INFO_CONF 1 /* fpathconf() *///-----------------------------------------------------------------------------// Modes for fsync()#define CYG_FSYNC 1#define CYG_FDATASYNC 2//-----------------------------------------------------------------------------// Get/set info buffer structures// This is used for pathconf() and fpathconf()struct cyg_pathconf_info{ int name; // POSIX defined variable name long value; // Returned variable value};//=============================================================================// Synchronization modes// These values are filled into the syncmode fields of the above structures// and define the synchronization protocol used when accessing the object in// question.#define CYG_SYNCMODE_NONE (0) // no locking required#define CYG_SYNCMODE_FILE_FILESYSTEM 0x0002 // lock fs during file ops#define CYG_SYNCMODE_FILE_MOUNTPOINT 0x0004 // lock mte during file ops#define CYG_SYNCMODE_IO_FILE 0x0010 // lock file during io ops#define CYG_SYNCMODE_IO_FILESYSTEM 0x0020 // lock fs during io ops#define CYG_SYNCMODE_IO_MOUNTPOINT 0x0040 // lock mte during io ops#define CYG_SYNCMODE_SOCK_FILE 0x0100 // lock socket during socket ops#define CYG_SYNCMODE_SOCK_NETSTACK 0x0800 // lock netstack during socket ops#define CYG_SYNCMODE_IO_SHIFT (4) // shift for IO to file bits#define CYG_SYNCMODE_SOCK_SHIFT (8) // shift for sock to file bits//=============================================================================// Mount and umount functions//__externC int mount( const char *devname, // const char *dir, // const char *fsname);//__externC int umount( const char *name);//=============================================================================// Get/Set info functions//__externC int cyg_fs_getinfo( const char *path, int key, void *buf, int len );//__externC int cyg_fs_setinfo( const char *path, int key, void *buf, int len );//__externC int cyg_fs_fgetinfo( int fd, int key, void *buf, int len );//__externC int cyg_fs_fsetinfo( int fd, int key, void *buf, int len );//=============================================================================// Select support//-----------------------------------------------------------------------------// Data structure for embedding in client data structures. A pointer to this// must be passed to cyg_selrecord() and cyg_selwakeup().struct CYG_SELINFO_TAG{ CYG_ADDRWORD si_info; // info passed through from fo_select() CYG_ADDRESS si_thread; // selecting thread pointer};//-----------------------------------------------------------------------------// Select support functions.// cyg_selinit() is used to initialize a selinfo structure.//__externC void cyg_selinit( struct CYG_SELINFO_TAG *sip );// cyg_selrecord() is called when a client device needs to register// the current thread for selection.//__externC void cyg_selrecord( CYG_ADDRWORD info, struct CYG_SELINFO_TAG *sip );// cyg_selwakeup() is called when the client device matches the select// criterion, and needs to wake up a selector.//__externC void cyg_selwakeup( struct CYG_SELINFO_TAG *sip );//=============================================================================// Timestamp support// Provides the current time as a time_t timestamp for use in filesystem// data strucures.//__externC time_t cyg_timestamp(void);//=============================================================================// Default functions.// Cast to the appropriate type, these functions can be put into any of// the operation table slots to provide the defined error code.//__externC int cyg_fileio_enosys(void);//__externC int cyg_fileio_erofs(void);//__externC int cyg_fileio_enoerr(void);//__externC int cyg_fileio_enotdir(void);//__externC cyg_fileop_select cyg_fileio_seltrue;//-----------------------------------------------------------------------------#endif // ifndef CYGONCE_FILEIO_H// End of fileio.h
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -