📄 file.h
字号:
/* *---------------------------------------------------------------------- * T-Kernel / Standard Extension * * Copyright (C) 2006 by Ken Sakamura. All rights reserved. * T-Kernel / Standard Extension is distributed * under the T-License for T-Kernel / Standard Extension. *---------------------------------------------------------------------- * * Version: 1.00.00 * Released by T-Engine Forum(http://www.t-engine.org) at 2006/8/11. * *---------------------------------------------------------------------- *//* * file.h (extension) * * File management */#ifndef __EXTENSION_FILE_H__#define __EXTENSION_FILE_H__#include <basic.h>#include "typedef.h"#ifdef __cplusplusextern "C" {#endif/* * Length of various names (number of characters) */#define L_FSNM 20 /* File system name */#define L_DLNM 20 /* Device location name */#define L_DEVNM 8 /* Logical device name */#define L_CONNM 8 /* Connection name */#define L_USRNM (12+2) /* User (group) name + hidden name */#define L_FNM 20 /* File name */#define L_PATHNM 256 /* Path name *//* * Various sizes */#define N_GRP 4 /* Number of included groups *//* * Special symbols used in path name */#define TC_FDLM 0xff21U /* Delimiter used in path name */#define TC_FSEP 0xff22U /* Delimiter for showing occurrence order */#define TC_FOWN 0xff23U /* ser (work file) *//* * Specification by get_lnk() */#define F_NORM 0x0000 /* Normal specification */#define F_BASED 0x0001 /* Base specification */#define F_DIRECT 0x0002 /* Specify direct fetching *//* * Specification by opn_fil() */#define F_READ 0x0004U /* Read-only open */#define F_WRITE 0x0002U /* Write-only open */#define F_UPDATE 0x0006U /* Open for update (read/write) */#define F_EXCL 0x0100U /* Exclusive mode */#define F_WEXCL 0x0200U /* Exclusive write mode *//* * Specification by cre_fil()/cre_lnk() */#define F_FLOAT 0x0000 /* Not specified as fixed link */#define F_FIX 0x0001 /* Specified as fixed link */#define F_FILEID 0x0002 /* Specify file ID *//* * Specification by fnd_rec()/fnd_lnk() */#define F_FWD 0x0000 /* Forward search */#define F_NFWD 0x0001 /* Forward search (starting from the next one) */#define F_BWD 0x0002 /* Backward search */#define F_NBWD 0x0003 /* Backward search (starting from the previous one) */#define F_TOPEND 0x0004 /* Start to end */#define F_ENDTOP 0x0005 /* End to start */#define F_SFILE 0x4000 /* Same file */#define F_SNAME 0x2000 /* Same file name */#define F_SATR1 0x1000 /* Same attribute data 1 */#define F_SATR2 0x0800 /* Same attribute data 2 */#define F_SATR3 0x0400 /* Same attribute data 3 */#define F_SATR4 0x0200 /* Same attribute data 4 */#define F_SATR5 0x0100 /* Same attribute data 5 *//* * Specification by loc_rec() */#define F_UNLOCK 0x0000 /* Unlock */#define F_LOCK 0x0001 /* Lock */#define F_TSLOCK 0x0002 /* Test & lock */#define F_CKLOCK 0x0003 /* Check lock state *//* * Specification by map_rec() */#define F_COMMON 0x0100 /* Map to shared memory space */#define F_SYSTEM 0x0300 /* Map to system memory space *//* * Specification by chk_fil() */#define F_READ 0x0004U /* R access check */#define F_WRITE 0x0002U /* W access check */#define F_EXCUTE 0x0001U /* E access check */#define F_EXIST 0x0000U /* Check existence of file */#define F_PASWD 0x0008U /* Existence of password *//* * Specification by chg_fat() */#define F_SETRONLY 0x0001U /* Set non-writable attribute */#define F_RSTRONLY 0x0002U /* Reset non-writable attribute */#define F_SETPERM 0x0003U /* Set non-deletable attribute */#define F_RSTPERM 0x0004U /* Reset non-deletable attribute */#define F_SETA1 0x0005U /* Set application attribute 1 */#define F_RSTA1 0x0006U /* Reset application attribute 1 */#define F_SETA2 0x0007U /* Set application attribute 2 */#define F_RSTA2 0x0008U /* Reset application attribute 2 *//* * Specification by att_fls() */#define FS_SYNC 0x0000U /* Synchronous */#define FS_ASYN 0x0002U /* Asynchronous */#define FS_RONLY 0x0001U /* Write protect *//* * Specification by lst_fls() */#define F_GETDEV (-1) /* Obtain corresponding device name */#define F_GETNAM (-2) /* Obtain corresponding connection name *//* * Function value in syn_lnk() */#define F_SYNC 0 /* Match */#define F_DNAME 1 /* File name is different. */#define F_DDATE 2 /* Generation date/time is different. */#define F_DBOTH 3 /* File name and creation date/time are different. *//* * Link */#if 0 /* Defined in typedef.h */typedef struct { TC fs_name[L_FSNM]; /* File system name */ UH f_id; /* File ID */ UH atr1; /* Attribute data 1 */ UH atr2; /* Attribute data 2 */ UH atr3; /* Attribute data 3 */ UH atr4; /* Attribute data 4 */ UH atr5; /* Attribute data 5 */} LINK;#endif/* * File access mode */typedef struct { UH f_ownacc; /* Owner access mode */ UH f_grpacc; /* Group access level */ UH f_pubacc; /* General access level */ H f_grpno; /* Group number */} A_MODE;/* * Default file access mode */typedef struct { UH f_ownacc; /* Owner access mode */ UH f_grpacc; /* Group access level */ UH f_pubacc; /* General access level */ H f_grpno; /* Group number */ UH f_gacc[N_GRP]; /* Group access level */} DA_MODE;/* * File date/time */typedef struct { STIME f_ltime; /* File storage period (date/time) */ STIME f_atime; /* Latest date/time of access */ STIME f_mtime; /* Latest date/time of update */} F_TIME;/* * File management information */typedef struct { UH f_type; /* File type/owner access mode */ UH f_atype; /* Application type */ TC f_owner[L_USRNM]; /* File owner name (hidden name is always 0) */ TC f_group[L_USRNM]; /* Owner group name (hidden name is always 0) */ UH f_grpacc; /* Group access level */ UH f_pubacc; /* General access level */ H f_nlink; /* Number of links included */ H f_index; /* Index level */ W f_size; /* Total number of file bytes */ W f_nblk; /* Total number of used logical blocks */ W f_nrec; /* Total number of records */ STIME f_ltime; /* File storage period (date/time) */ STIME f_atime; /* Latest date/time of access */ STIME f_mtime; /* Latest date/time of update */ STIME f_ctime; /* Creation date/time of file */} F_STATE;/* * Specify file type (f_type) */#define F_FILE 0x1000U /* Normal file */#define F_APLATR1 0x0040U /* Application attribute 1 */#define F_APLATR2 0x0080U /* Application attribute 2 */#define F_RONLY 0x0010U /* Non-writable attribute */#define F_PERM 0x0020U /* Non-deletable attribute */#define F_OWNACC 0x0007U /* Owner access attribute (RWE) */#define F_OWNACR 0x0004U /* Owner R access attribute */#define F_OWNACW 0x0002U /* Owner W access attribute */#define F_OWNACE 0x0001U /* Owner E access attribute */#define F_NOCHG 0x8000U /* Not change *//* * File location information */typedef struct { STIME fs_ctime; /* Generation date/time of file system */ TC fs_name[L_FSNM]; /* File system name */ TC fs_locat[L_DLNM]; /* Device location name */ TC fs_dev[L_DEVNM]; /* Logical device name */} F_LOCATE;/* * Link information */typedef struct { STIME f_ctime; /* Generation date/time of link file */ UH f_atype; /* Application type of reference file */ TC f_name[L_FNM]; /* Reference file name */ UH f_id; /* Reference file ID */ STIME rf_ctime; /* Generation date/time of reference file */ TC fs_name[L_FSNM]; /* File system name */ TC fs_locat[L_DLNM]; /* Device location name of file system */} F_LINK;/* * Management information of file system */typedef struct { UH fs_bsize; /* Number of logical block bytes */ UH fs_nfile; /* Maximum number of files */ H fs_lang; /* Language used in file system */ H fs_level; /* Access management level of file system */ W fs_nblk; /* Total number of blocks */ W fs_nfree; /* Total number of unused blocks */ STIME fs_mtime; /* Latest update date/time of system block */ STIME fs_ctime; /* Generation date/time of file system */ TC fs_name[L_FSNM]; /* File system name */ TC fs_locat[L_DLNM]; /* Device location name */} FS_STATE;/* * Specify language to use (fs_lang) */#define F_JPN 0x0021 /* Japanese (Japanese character group) */#define F_ENG 0x0080 /* English (Roman character group 1) *//* * File system connection information */typedef struct { TC a_name[L_CONNM]; /* Connection name */ TC dev[L_DEVNM]; /* Logical device name */} F_ATTACH;/* * Definitions for automatic generation of interface library (mkiflib) *//*** DEFINE_IFLIB[INCLUDE FILE]<extension/file.h>[PREFIX]FM***/#ifndef __phyblk__typedef struct phyblk PhyBlk; /* Defined in segment.h */#define __phyblk__#endif/* * File management system call *//* [BEGIN SYSCALLS] */IMPORT ER tkse_get_lnk(TC *path, LINK *lnk, W mode);IMPORT ER tkse_chg_wrk(LINK *lnk);IMPORT ER tkse_cre_fil(LINK *lnk, TC *name, A_MODE *mode, UH atype, W opt);IMPORT ER tkse_cre_lnk(LINK *lnk, F_LINK *ref, W opt);IMPORT ER tkse_gen_fil(LINK *lnk, TC *name, F_STATE *stat, F_LINK *ref, W opt);IMPORT ER tkse_opn_fil(LINK *lnk, W o_mode, TC *pwd);IMPORT ER tkse_cls_fil(W fd);IMPORT ER tkse_del_fil(LINK *org, LINK *lnk, W force);IMPORT ER tkse_see_rec(W fd, W offset, W mode, W *recnum);IMPORT ER tkse_fnd_rec(W fd, W mode, UW typemask, UH subtype, W *recnum);IMPORT ER tkse_fnd_lnk(W fd, W mode, LINK *lnk, UH subtype, W *recnum);IMPORT ER tkse_rea_rec(W fd, W offset, B *buf, W size, W *r_size, UH *subtype);IMPORT ER tkse_wri_rec(W fd, W offset, B *buf, W size, W *r_size, UH *subtype, UW units);IMPORT ER tkse_ins_rec(W fd, B *buf, W size, W type, UH subtype, UW units);IMPORT ER tkse_apd_rec(W fd, B *buf, W size, W type, UH subtype, UW units);IMPORT ER tkse_del_rec(W fd);IMPORT ER tkse_trc_rec(W fd, W size);IMPORT ER tkse_xch_fil(W fd_1, W fd_2);IMPORT ER tkse_loc_rec(W fd, W mode);IMPORT ER tkse_chk_fil(LINK *lnk, W mode, TC *pwd);IMPORT ER tkse_chg_fmd(LINK *lnk, A_MODE *mode);IMPORT ER tkse_chg_fat(LINK *lnk, W attr);IMPORT ER tkse_chg_fnm(LINK *lnk, TC *name);IMPORT ER tkse_chg_ftm(LINK *lnk, F_TIME *times);IMPORT ER tkse_fil_sts(LINK *lnk, TC *name, F_STATE *stat, F_LOCATE *locat);IMPORT ER tkse_ofl_sts(W fd, TC *name, F_STATE *stat, F_LOCATE *locat);IMPORT ER tkse_lnk_sts(LINK *lnk, F_LINK *stat);IMPORT ER tkse_syn_lnk(LINK *lnk, W opt);IMPORT ER tkse_get_dfm(DA_MODE *mode);IMPORT ER tkse_set_dfm(DA_MODE *mode);IMPORT ER tkse_att_fls(TC *dev, TC *name, LINK *lnk, UW mode);IMPORT ER tkse_det_fls(TC *dev, W eject);IMPORT ER tkse_syn_fls(void);IMPORT ER tkse_fls_sts(TC *dev, FS_STATE *buff);IMPORT ER tkse_chg_fls(TC *dev, TC *fs_name, TC *fs_locate);IMPORT ER tkse_get_nlk(LINK *lnk);IMPORT ER tkse_lst_fls(F_ATTACH *buff, W cnt);IMPORT ER tkse_map_rec(W fd, W offset, B **addr, W size, W mode);IMPORT ER tkse_ump_rec(W fd, W mapid);IMPORT ER tkse_chg_fsm(TC *dev, UW mode);IMPORT ER tkse_syn_fil(W fd);/* ALIGN_NO 0x1000 *//* * System call for internal use by OS */IMPORT ER tkse_GetRecInfo(W fd, W *offset, W *recsize, PhyBlk *block, W entry_len, W *n_entry);/* [END SYSCALLS] */#ifdef __cplusplus}#endif#endif /* __EXTENSION_FILE_H__ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -