From 31b52bc208f444becd1dea240dfd6c54c7cb906f Mon Sep 17 00:00:00 2001 From: Remzi Arpaci-Dusseau Date: Wed, 1 Dec 2021 13:04:43 -0600 Subject: [PATCH] link to mfs.h --- filesystems-distributed/README.md | 2 +- filesystems-distributed/mfs.h | 71 +++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 filesystems-distributed/mfs.h diff --git a/filesystems-distributed/README.md b/filesystems-distributed/README.md index 2103eec..4e7a735 100644 --- a/filesystems-distributed/README.md +++ b/filesystems-distributed/README.md @@ -17,7 +17,7 @@ representation of your data structures; you should use these system calls to access it: `open(), read(), write(), lseek(), close(), fsync().` To access the file server, you will be building a client library. The -interface that the library supports is defined in XXX MFS.H XXX. The +interface that the library supports is defined in [mfs.h](mfs.h). The library should be called `libmfs.so`, and any programs that wish to access your file server will link with it and call its various routines. diff --git a/filesystems-distributed/mfs.h b/filesystems-distributed/mfs.h new file mode 100644 index 0000000..097ffb5 --- /dev/null +++ b/filesystems-distributed/mfs.h @@ -0,0 +1,71 @@ +#ifndef __MFS_h__ +#define __MFS_h__ + +#define MFS_DIRECTORY (0) +#define MFS_REGULAR_FILE (1) +#define BUFFER_SIZE (4096) +#define MFS_BLOCK_SIZE (4096) +#define DIR_NAME_LENGTH (28) +#define NUM_INODES (4096) + +#define INIT (0) +#define LOOKUP (1) +#define STAT (2) +#define WRITE (3) +#define READ (4) +#define CREATEF (5) +#define CREATED (6) +#define UNLINK (7) +#define SHUTDOWN (8) + + +typedef struct __MFS_Stat_t { + int type; // MFS_DIRECTORY or MFS_REGULAR + int size; // bytes + // note: no permissions, access times, etc. +} MFS_Stat_t; + +typedef struct __MFS_DirEnt_t { + char name[28]; // up to 28 bytes of name in directory (including \0) + int inum; // inode number of entry (-1 means entry not used) +} MFS_DirEnt_t; + +typedef struct __request{ + int action; //The action requested from the server + int inum; //inode number of file to be acted on + int pinum; //inode number of parent directory--used when creating files + int block; //Block to be read + int port; //portname to connect to server on + char buf[MFS_BLOCK_SIZE]; //Multiple meanings, depending on the action requested +}request; + +typedef struct __reply{ + int inum; + MFS_Stat_t m; + int rc; + char read_data[MFS_BLOCK_SIZE]; +}reply; +typedef struct checkpoint{ + int endptr; + int mapptrs[256]; +}checkpoint; + + +typedef struct inode{ + int size; + int type; + int ptrs[14]; + +}inode; + + + +int MFS_Init(char *hostname, int port); +int MFS_Lookup(int pinum, char *name); +int MFS_Stat(int inum, MFS_Stat_t *m); +int MFS_Write(int inum, char *buffer, int block); +int MFS_Read(int inum, char *buffer, int block); +int MFS_Creat(int pinum, int type, char *name); +int MFS_Unlink(int pinum, char *name); +int MFS_Shutdown(void); +#endif // __MFS_h__