head 1.4; branch ; access ; symbols ; locks ; comment @@; 1.4 date 1996.02.15.22.25.06; author Sven_Goethel; state Exp; branches ; next 1.3; 1.3 date 1996.02.13.06.35.57; author Sven_Goethel; state Exp; branches ; next 1.2; 1.2 date 1995.11.29.02.49.40; author Sven_Goethel; state Exp; branches ; next 1.1; 1.1 date 1995.11.29.02.26.06; author Sven_Goethel; state Exp; branches ; next ; desc @@ 1.4 log @see rcfs.c @ text @#ifndef _RC_FS_H #define _RC_FS_H #include #ifndef _C166_ #include #else #define _WITH_KL_806_ #define assert(a) if(!(a))INT_ERR(__LINE__); #endif #include "metatype.h" #ifdef _WITH_KL_806_ # ifndef _C166_ # define STDH66 /* stop use c166 prototypes for TERMINAL.66 */ # endif # include "mainterm.h" # include "termdac1.h66" #endif #include "permssn.h" /* a try to kill inode managment overhead while reading .. writing */ #define _HANDLE_WITH_INODE_ /* because of a bug in the kl806-block-file-system of version BF1.3e BETA, the maximum ramcard size is restricted to 65024 Bytes. if '__KL806_BF1_3e__' is defined the format command will only use the 65024 bytes ! */ #define __KL806__ #define __KL806_BF1_3f__ #define KL806_VERSION "1.3f BETA" /* * $Log: rcfs.h $ * Revision 1.3 1996/02/13 06:35:57 Sven_Goethel * it works * Revision 1.2 1995/11/29 02:49:40 Sven_Goethel * *** empty log message *** */ /* rc_fs a simple file-system including a directory-structure and permittion control. this fs is created for the pcmcia-ramcard, or other devices ... the minix-filesystem (a LINUX-Filesystem) teached me how to implement. Because of magic conditions of the ramcard low level filesystem (fs), supported by Duerkopp-Adler(DA), the block-size is fixed by 256. Also the first seventeen bytes must be non zero and the last block byte (rel adress 0xff) is used for the 8 bit CRC-Checksum !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! All those things will give this ramcard-filesystem (rc-fs) a non flexible structure. The 18 Bytes garbage will also reduce the totally amount of netto ram size of the fs !!!!!!!!!!!!!!!!!!!!!!!!!! */ /* rc_fs UPDATE The ramcard low level filesystem (fs) supported by Duerkopp-Adler(DA), contains true raw-block level functions NOW ! All restrictions described upper, are removed ! */ /* IMPLEMENTATION-NOTES ===================== o The RCFS-Filesystem is created in a defined layer model. o A layer is an implementation level. o The level 0 means a low-level layer, the level 1 means a higher-level layer, and so on. o Functions defined in one layer can NEVER call a function defined in a higher layer. o Functions defined in one layer can allways call a function defined in a lower layer. o Normally, except the level 3 (user-level-functions), a function in one layer only calls functions in the next lower layer. LEVEL PERMISSION : LEVEL # CAN ACCESS LEVEL DESCRIPTION ======================================================== 0 - Basic I/O-Block-Functions 1 0 Inode and Zone (inode-depending) I/O-Functions 2 1 Inode (dir-depending) Functions 3 2,1,0 User Functions (deklared here) */ /* rc := ramcard fs := filesystem inode := information node ( the fs structure ) sb := superblock ( contains fs geometrics and magic number ) bmp := bitmap ( contains marks for used/unused inodes/datazones ) crc := checksum defined as followed crc := 0 for ( i=0; i inumber */ /* rc_getinode, rc_putinode gets or puts the inode includes validation checking ! puts saves the inode to the media ! */ /* rc_rminode removes an inode with all its data-zone's ( but does not take care if inode respons to a directory, for directory integrity use LEVEL 3 fkt. ) f(inumber) -> nil */ rc_state rc_createinode(unsigned short *inumber, unsigned short user, unsigned short group, unsigned short uid); rc_state rc_getinode(rc_inode *inode, unsigned short inumber); rc_state rc_putinode(rc_inode *inode, unsigned short inumber); rc_state rc_rminode(unsigned short inumber); /* RC-FS : LEVEL 2 */ /* =============== */ const char * rc_getuidstr(unsigned short uid); /* TestPermission checks the permission for inode access, return true if OK */ bool TestPermission(const rc_inode *inode, unsigned short user, unsigned short group, unsigned short mode ); /* rc_mkdirinode : f(dir_inumber,name,usr,grp,uid) -> new_inumber If uid contents the RC_DIR bit, this functions assumes that a new directory will be created ! In this case a data block for the inode will be created with the general files '.' and '..' !!!!!!!!!!!!!!! Otherwise the inode does not reference any block, so that the file size equals zero !!!!!!! The function checks if the name ( no slashes etc. are allowed ) does allready exist. READ/WRITE permission for dir_inumber will be checked ! */ /* rc_getdirinode : f(dir_inumber,usr,grp,name) -> inumber Trys to receive the fitting inode-number according to the file 'name' the 'name' can be a valid filename included '.' and '..' !!! READ permission for dir_inumber will be checked ! */ /* rc_rmdirinode : f(dir_inumber, name, recursive) -> nil removes the found file 'name' in the directory 'dir_inumber', if the found file is an directory, the flag 'recursive' indicates, if the whole directory include its sub-directorys and files will be removed !!! READ/WRITE permission for dir_inumber will be checked ! */ rc_state rc_mkdirinode(unsigned short *new_inumber, unsigned short dir_inumber, const char *name, unsigned short user, unsigned short group, unsigned short uid); rc_state rc_getdirinode(unsigned short *inumber, unsigned short dir_inode, unsigned short user, unsigned short group, const char *name ); rc_state rc_rmdirinode(unsigned short dir_inumber, const char *name, unsigned short user, unsigned short group, bool recursiv ); /* RC-FS : LEVEL 3 -- USER LEVEL */ /* -- to provide file permissions, you will need the permssn.c/h module !!!!!!!!!!!!!!!!!!! */ rc_state rc_mount(bool write_back); rc_state rc_umount(void); rc_state rc_checkfs(bool verbose); rc_state rc_format(unsigned short blk_sz, double inode_pct, unsigned short uid ); rc_state rc_mkdir(const char *fname); rc_state rc_cd(const char *fname); rc_state rc_dir(char *dest, unsigned short dest_sz, char *prefix, bool recursiv, bool flong); rc_state rc_rm(const char *fname, bool recursiv); rc_state rc_remove(const char *fname); rc_state rc_IsExistFile (const char *name, bool *flag); rc_state rc_IsExistDir (const char *name, bool *flag); rc_state rc_IsExist (const char *name, bool *flag); /* rc_open modes : (READ WRITE like the SB - STATES) */ #ifndef RC_READ #define RC_READ 4U #endif #ifndef RC_WRITE #define RC_WRITE 8U #endif #ifndef RC_RDWR #define RC_RDWR 12U #endif #define RC_BINARY 16U /* ignored */ #define RC_TEXT 32U /* ignored */ #define RC_CREATE 64U #define RC_APPEND 128U #define RC_DEF_FILE_BUFFER_SZ 1024 typedef struct { unsigned short inumber; /* the inode-number off .. */ unsigned short open_mode; unsigned short mode; unsigned long byte_pos; bool eof; /* things to support buffered access */ unsigned char *buffer; unsigned short bufferidx; unsigned short buffersz; #ifdef _HANDLE_WITH_INODE_ rc_inode inode; #endif } rc_handle; void rc_set_fbuffer_sz(unsigned short sz); rc_handle * rc_open(const char *fname, unsigned short mode); rc_state rc_close(rc_handle *hdle); rc_state rc_rewind(rc_handle *hdle); rc_state rc_flush(rc_handle *hdle); rc_state rc_geterr(void); int rc_iseof(rc_handle *hdle); unsigned short rc_write(rc_handle *hdle, const unsigned char *mem, unsigned short size ); unsigned short rc_read(rc_handle *hdle, unsigned char *mem, unsigned short size); /* whence for rc_fseek : ====================== SEEK_SET : Sucht ab Dateianfang SEEK_CUR : Sucht ab der aktuellen Position SEEK_END : Sucht vom Dateiende her */ #ifndef SEEK_SET #define SEEK_SET 0 #endif #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif int rc_fseek(rc_handle *hdle, long offset, int whence); unsigned long rc_ftell(rc_handle *hdle); int rc_printf(rc_handle *hdle, const char *fmt, ... ); int rc_getc(rc_handle *hdle); unsigned short rc_puts(const char *str, rc_handle *hdle); unsigned short rc_putc(char c, rc_handle *hdle); void rc_put_err(rc_state state); const char * rc_get_err(rc_state state); #endif @ 1.3 log @it works @ text @d37 2 d241 2 d249 1 d251 14 a264 1 All functions do notice the sb-entrys for the GARBAGE space !!! d266 4 d283 3 @ 1.2 log @*** empty log message *** @ text @d1 2 d4 8 d13 112 d125 5 a129 2 #ifndef _RC_FS_H #define _RC_FS_H d131 8 a138 3 /* * $Log: rcfs.h $ */ d140 3 a142 5 /* rc_fs a simple file-system including a directory-structure and permittion control. this fs is created for the pcmcia-ramcard, or other devices ... the minix-filesystem (a LINUX-Filesystem) teached me how to implement. a143 10 Because of magic conditions of the ramcard low level filesystem (fs), supported by Duerkopp-Adler(DA), the block-size is fixed by 256. Also the first seventeen bytes must be non zero and the last block byte (rel adress 0xff) is used for the 8 bit CRC-Checksum !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! All those things will give this ramcard-filesystem (rc-fs) a non flexible structure. The 18 Bytes garbage will also reduce the totally amount of netto ram size of the fs !!!!!!!!!!!!!!!!!!!!!!!!!! */ d145 3 a147 9 /* rc := ramcard fs := filesystem inode := information node ( the fs structure ) sb := superblock ( contains fs geometrics and magic number ) bmp := bitmap ( contains marks for used/unused inodes/datazones ) crc := checksum defined as followed crc := 0 for ( i=0; i new_inode, inumber */ /* rc_getinode gets a numbered inode and returns it */ /* rc_rminode removes an inode with all its data-zone's ( non sub-directorys ( for integrity rm use LEVEL 3 fkt. ) ) f(inumber) -> inode */ rc_error rc_createinode(rc_inode *, unsigned short *inumber, unsigned char user, unsigned char group, unsigned short uid); rc_error rc_getinode(rc_inode *, unsigned short inumber); rc_error rc_rminode(unsigned short inumber); d438 4 a441 5 /* RC-FS : LEVEL 3 */ /* rc_mkdirinode : f(parent_inode,name,usr,grp,uid) -> new_inode, new_inumber */ /* rc_getdirentry : f(parent_inode,dir_entry_number) -> rc_dir_entry */ /* rc_getdirinode : f(parent_inode,name) -> inode, inumber */ /* rc_rmdirinode : f(inumber) -> nil */ d443 3 a445 12 rc_error rc_mkdirinode(rc_inode *new_inode, unsigned short *new_inumber, const rc_inode *parent_inode, const char *name, unsigned char user, unsigned char group, unsigned short uid); rc_error rc_getdirentry(rc_dir_entry *, const rc_inode *parent_inode, unsigned short dnumber); rc_error rc_getdirinode(rc_inode *inode, unsigned short *inumber, const rc_inode *parent_inode, const char *name); rc_error rc_rmdirinode(unsigned short inumber); d447 2 d450 2 a451 4 /* RC-FS : LEVEL 4 -- USER LEVEL */ /* -- to provide file permissions, you will need the permssn.c/h module !!!!!!!!!!!!!!!!!!! */ d453 3 a455 12 /* rc_open modes : (READ WRITE like the SB - STATES) */ #ifndef RC_READ #define RC_READ 4 #endif #ifndef RC_WRITE #define RC_WRITE 8 #endif #ifndef RC_RDWR #define RC_RDWR 12 #endif #define RC_BINARY 16 #define RC_TEXT 32 d457 2 a458 8 rc_error rc_format(unsigned char blk_sz, unsigned char rc_sz, char inode_pct, unsigned short uid); rc_error rc_mkdir(const char *, unsigned char user, unsigned char group, unsigned short uid); rc_error rc_cd(const char *, unsigned char user, unsigned char group, unsigned short uid); rc_error rc_rmdir(const char *, unsigned char user, unsigned char group, unsigned short uid); d460 3 a462 3 rc_error rc_open(rc_handle *, const char *fname, unsigned char mode); rc_error rc_close(rc_handle ); rc_error rc_remove(const char *); d464 14 a477 2 unsigned short rc_write(rc_handle rch, const BYTE *mem, unsigned short size); unsigned short rc_read(rc_handle rch, BYTE *mem, unsigned short size); d479 1 a479 3 unsigned short rc_printf(rc_handle rch, const char *fmt, ... ); unsigned short rc_getc(rc_handle rch); unsigned short rc_putc(char c, rc_handle rch); d481 14 a494 2 char *rc_gets(BYTE *str, unsigned short n, rc_handle rch); int fputs(const BYTE *str, rc_handle rch); d496 42 @ 1.1 log @Initial revision @ text @d6 4 d15 10 d50 10 a83 1 #define MIN_BLCK_SIZE 256 /* minimum block size */ d100 3 a102 2 max_blks := rc_sz / blk_sz - 1 ^for SB d141 10 d153 3 a155 1 unsigned char blk_sz; /* variable block size support */ @