📄 osapi-os-filesys.h
字号:
/*** File: osapi-os-filesys.h**** Author: Alan Cudmore Code 582**** Purpose: Contains functions prototype definitions and variables declarations** for the OS Abstraction Layer, File System module**** $Revision: 1.26 $ **** $Date: 2005/07/12 17:13:56 $**** $Log: osapi-os-filesys.h,v $** Revision 1.26 2005/07/12 17:13:56 nyanchik** Moved the Volume table to a bsp table in the arch directories.**** Revision 1.2 2005/07/11 16:26:57EDT apcudmore ** OSAPI 2.0 integration** Revision 1.25 2005/07/06 16:11:17 nyanchik** *** empty log message ******* Revision 1.24 2005/07/05 18:34:55 nyanchik** fixed issues found in code walkthrogh. Also removed the OS_Info* functions that are going in the BSP**** Revision 1.23 2005/06/17 19:46:34 nyanchik** added new file system style to linux and rtems.**** Revision 1.22 2005/06/15 16:43:48 nyanchik** added extra parenthesis for the .h file # defines**** Revision 1.21 2005/06/06 14:17:42 nyanchik** added headers to osapi-os-core.h and osapi-os-filesys.h**** Revision 1.20 2005/06/02 18:04:24 nyanchik** *** empty log message ******* Revision 1.1 2005/03/15 18:26:32 nyanchik** *** empty log message ********* Date Written:**** */#ifndef _osapi_filesys_#define _osapi_filesys_#include <stdio.h>#include <stdlib.h>#include <dirent.h>#include <sys/stat.h>#define OS_READ_ONLY 0#define OS_WRITE_ONLY 1#define OS_READ_WRITE 2#define OS_SEEK_SET 0#define OS_SEEK_CUR 1#define OS_SEEK_END 2#define OS_CHK_ONLY 0#define OS_REPAIR 1#define FS_BASED 0#define RAM_DISK 1#define FLASH_DISK_FORMAT 2#define EEPROM 3#define FLASH_DISK_INIT 4/*** Number of entries in the internal volume table*/#define NUM_TABLE_ENTRIES 4/*** Defines for File System Calls*/#define OS_FS_SUCCESS 0#define OS_FS_ERROR (-1)#define OS_FS_ERR_INVALID_POINTER (-2) #define OS_FS_ERR_PATH_TOO_LONG (-3)#define OS_FS_ERR_NAME_TOO_LONG (-4)#define OS_FS_UNIMPLEMENTED (-5) #define OS_FS_ERR_DRIVE_NOT_CREATED (-6)#define OS_FS_ERR_DEVICE_NOT_FREE (-7)/* This typedef is for the OS_FS_GetErrorName function, to ensure * everyone is making an array of the same length */typedef char os_fs_err_name_t[35];/*** Internal structure of the OS volume table for ** mounted file systems and path translation*/typedef struct{ char DeviceName [32]; char PhysDevName [32]; uint32 VolumeType; uint8 VolatileFlag; uint8 FreeFlag; uint8 IsMounted; char VolumeName [32]; char MountPoint [64]; uint32 BlockSize;}OS_VolumeInfo_t;/* modified to posix calls, since all of the * applicable OSes use the posix calls */typedef struct stat os_fstat_t;typedef DIR* os_dirp_t;typedef struct dirent os_dirent_t;/* still don't know what this should be*/typedef unsigned long int os_fshealth_t; /* * Exported Functions*//******************************************************************************** Standard File system API******************************************************************************//* * Creates a file specified by path*/int32 OS_creat (const char *path, uint32 access);/* * Opend a file for reading/writing. Returns file descriptor*/int32 OS_open (const char *path, uint32 mode, uint32 access);/* * Closes an open file.*/int32 OS_close (uint32 filedes);/* * Reads nbytes bytes from file into buffer*/int32 OS_read (uint32 filedes, void *buffer, uint32 nbytes);/* * Write nybytes bytes of buffer into the file*/int32 OS_write (uint32 filedes, void *buffer, uint32 nbytes);/* * Changes the permissions of a file*/int32 OS_chmod (const char *path, uint32 access);/* * Returns file status information in filestats*/int32 OS_stat (const char *path, os_fstat_t *filestats);/* * Seeks to the specified position of an open file */int32 OS_lseek (uint32 filedes, int32 offset, uint32 whence);/* * Removes a file from the file system*/int32 OS_remove (const char *path);/* * Renames a file in the file sysetm*/int32 OS_rename (const char *old, const char *new);/******************************************************************************** Directory API ******************************************************************************//* * Makes a new directory*/int32 OS_mkdir (const char *path, uint32 access);/* * Opens a directory for searching*/os_dirp_t OS_opendir (const char *path);/* * Closes an open directory*/int32 OS_closedir(os_dirp_t directory);/* * Reads the next object in the directory*/os_dirent_t * OS_readdir (os_dirp_t directory);/* * Removes an empty directory from the file system.*/int32 OS_rmdir (const char *path);/******************************************************************************** System Level API ******************************************************************************//* * Initializes the file system*/void OS_FS_Init(void);/* * Makes and mounts a file system*/int32 OS_mkfs (char *address,char *devname, char *volname, uint32 blocksize, uint32 numblocks);/* * Mounts a file system*/int32 OS_mount (const char *devname, char *mountpoint);/* * Unmounts a mounted file system*/int32 OS_unmount (const char *mountpoint);/* * Returns the number of free blocks in a fiile system*/int32 OS_fsBlocksFree (const char *name);/* * Checks the health of a file system and repairs it if neccesary*/os_fshealth_t OS_chkfs (const char *name, boolean repair);/* * Returns the name of the given error in the err_name struct*/int32 OS_FS_GetErrorName (int32 error_num, os_fs_err_name_t * err_name);#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -