/branches/fs/kernel/generic/src/lib/rd.c |
---|
47,6 → 47,11 |
static parea_t rd_parea; /**< Physical memory area for rd. */ |
/** |
* RAM disk initialization routine. At this point, the RAM disk memory is shared |
* and information about the share is provided as sysinfo values to the userspace |
* tasks. |
* / |
int init_rd(rd_header * header, size_t size) |
{ |
//printf("Header magic %c%c%c%c\n",header->magic[0],header->magic[1],header->magic[2],header->magic[3]); |
/branches/fs/uspace/share/shared_proto.h |
---|
1,5 → 1,40 |
/* Shared prototypes for tasks Cat and FS */ |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemTask |
* @{ |
*/ |
/** |
* @file shared_proto.h |
* @brief Shared prototypes for tasks Cat and FS |
*/ |
#ifndef _SHARED_PROTO_H |
#define _SHARED_PROTO_H |
20,3 → 55,8 |
#endif /* _SHARED_PROTO_H */ |
/** |
*} |
*/ |
/branches/fs/uspace/share/message.c |
---|
1,13 → 1,41 |
/* Sending extended well formed messages to FS over |
* standard HelenOS message agrs and over shared buffer. |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* Methods: |
* send_request: forms and sends extended message to FS |
* unpack_message: unpacks message to given message_params_t* structure |
/** @addtogroup FileSystemTask |
* @{ |
*/ |
/** |
* @file message.c |
* @brief Sending extended well formed messages to FS over |
* standard HelenOS message agrs and over shared buffer. |
*/ |
#include <async.h> |
#include <task.h> |
#include "../fs/fs.h" |
16,7 → 44,10 |
int send_request(int phoneid, ipcarg_t method, message_params_t *params, void *shared_buffer); |
void unpack_message(message_params_t *message, ipc_call_t m_input, void *shared_buffer); |
/* This method should be used by all callers of FS. Candidate at library function. */ |
/** |
* Forms and sends extended message to FS |
* This method should be used by all callers of FS. Candidate at library function. |
*/ |
int send_request(int phoneid, ipcarg_t method, message_params_t *params, void *shared_buffer) |
{ |
42,7 → 73,10 |
return retval; |
} |
/* Will be used by FS to unpacking incoming extended message. */ |
/** |
* Unpacks message to given message_params_t* structure |
* Will be used by FS to unpacking incoming extended message. |
*/ |
void unpack_message(message_params_t *message, ipc_call_t m_input, void *shared_buffer) |
{ |
63,3 → 97,8 |
memcpy((void *)(&message->entry_number), (void *)(shared_buffer + shift), sizeof(int)); |
} |
/** |
*} |
*/ |
/branches/fs/uspace/share/base_const.h |
---|
1,10 → 1,50 |
/* Base constants. */ |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemTask |
* @{ |
*/ |
/** |
* @file base_const.h |
* @brief Definition of base constants for the FS task. |
*/ |
#ifndef _BASE_CONST_H |
#define _BASE_CONST_H |
#define FALSE 0 /* used for turning integers into Booleans */ |
#define TRUE 1 |
#define OK 0 |
#define FALSE 0 /**< False value - used for turning integers into Booleans */ |
#define TRUE 1 /**< True value - used for turning integers into Booleans */ |
#define OK 0 /**< A success return value */ |
#endif /* _BASE_CONST_H */ |
/** |
*} |
*/ |
/branches/fs/uspace/share/connect.c |
---|
1,18 → 1,47 |
/* Functions for connecting to some services, which is needed for FS. */ |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/* Methods: |
* common_connection: includes common aspects for connecting to some services |
* con_connection: connects to SERVICE_CONSOLE |
* rd_connection: connects to SERVICE_RD |
* fs_connection: connects to SERVICE_FS |
* |
/** @addtogroup FileSystemTask |
* @{ |
*/ |
/** |
* @file connect.h |
* @brief Functions for connecting to some services, which is needed for FS. |
*/ |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
#include "../fs/fs.h" |
/** |
* Includes common aspects for connecting to some services |
*/ |
int common_connection(int *phone, int service, int attempts) |
{ |
36,7 → 65,9 |
return FALSE; |
} |
/** |
* Connects to SERVICE_CONSOLE |
*/ |
int connect_to_con(int *phone, int attempts) |
{ |
46,6 → 77,9 |
return FALSE; |
} |
/** |
* Connects to SERVICE_RD |
*/ |
int connect_to_rd(int *phone, int attempts) |
{ |
55,6 → 89,9 |
return FALSE; |
} |
/** |
* Connects to SERVICE_FS |
*/ |
int connect_to_fs(int *phone, int attempts) |
{ |
63,3 → 100,8 |
return FALSE; |
} |
/** |
*} |
*/ |
/branches/fs/uspace/share/message.h |
---|
1,22 → 1,62 |
/* Extended message structure, which is used for communicating between FS |
* and its consuments. |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemTask |
* @{ |
*/ |
/** |
* @file message.h |
* @brief Extended message structure, which is used for communicating between FS |
* and its consuments. |
*/ |
#ifndef _MESSAGE_H |
#define _MESSAGE_H |
/* Declaration of the extended message structure as it is in the call and buffer. */ |
/** |
* Declaration of the extended message structure as it is in the call and buffer. |
*/ |
typedef struct { |
ipcarg_t id_task; /* id of currently consument */ |
ipcarg_t fd; /* file descriptor */ |
ipcarg_t whence; /* start position of SEEK */ |
ipcarg_t id_task; /**< id of currently consument */ |
ipcarg_t fd; /**< file descriptor */ |
ipcarg_t whence; /**< start position of SEEK */ |
/* Parameters which are present only in the buffer. */ |
unsigned int nbytes; /* number of bytes which will be read */ |
offset_t offset; /* offset of SEEK */ |
char fname[DIRSIZEX]; /* file name */ |
int entry_number; /* number of directory entry */ |
unsigned int nbytes; /**< number of bytes which will be read */ |
offset_t offset; /**< offset of SEEK */ |
char fname[DIRSIZEX]; /**< file name */ |
int entry_number; /**< number of directory entry */ |
} message_params_t; |
#endif /* _MESSAGE_H */ |
/** |
*} |
*/ |
/branches/fs/uspace/rd/rd.c |
---|
1,5 → 1,5 |
/* |
* Copyright (c) 2006 Martin Decky |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup rd |
/** @addtogroup RamDiskTask |
* @{ |
*/ |
/branches/fs/uspace/rd/rd.h |
---|
1,12 → 1,50 |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup RamDiskTask |
* @{ |
*/ |
/** |
* @file rd.h |
* @brief Initial RAM disk for HelenOS - header |
*/ |
/* Basic constants. */ |
#ifndef _RD_H |
#define _RD_H |
#define BLOCK_SIZE 1024 |
#define BLOCK_SIZE 1024 /**< Working block size */ |
#define RD_OFFSET 100 |
#define RD_BASE (FIRST_USER_METHOD + RD_OFFSET) |
#define RD_READ_BLOCK (RD_BASE + 1) |
#define RD_OFFSET 100 /**< IPC Message offset */ |
#define RD_BASE (FIRST_USER_METHOD + RD_OFFSET) /**< IPC Index of the first RD message */ |
#define RD_READ_BLOCK (RD_BASE + 1) /**< IPC Index of the RD_READ_BLOCK message */ |
#endif /* _RD_H */ |
/branches/fs/uspace/cat/cat.standard.c |
---|
1,10 → 1,38 |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FSDemo |
* @{ |
*/ |
/** |
* @file cat.c |
* @brief A file system demonstration task |
* @file cat.standard.c |
* @brief A file system demonstration task - standard library version |
*/ |
18,6 → 46,10 |
#include <io/file.h> |
#include <io/stat.h> |
/** |
* This is a very basic linear demonstration script of the standard file library |
*/ |
int main(int argc, char *argv[]) |
{ |
30,7 → 62,7 |
printf("Cat task\n"); |
/* File list in working directory. */ |
/* printf("File list:\n"); |
printf("File list:\n"); |
dir_items = ls(&dir_items_length); |
printf("Got a list\n"); |
40,12 → 72,12 |
printf("File name: %s\n", dir_items[entry].name); |
} |
*/ |
/* We want to change working directory */ |
retval = chdir("uspace/fs"); |
/* We want to work with specified file. */ |
/* file = fopen("fs.c", F_MODE_READ); |
file = fopen("fs.c", F_MODE_READ); |
retval = fstat( file ); |
printf("Info about file: %s\n", file->base_info.name); |
71,11 → 103,10 |
printf("\nContent of the buffer:\n"); |
printf(buffer); |
printf("\n\n"); |
*/ |
/* close the file */ |
// retval = fclose( file ); |
/*close the file */ |
retval = fclose( file ); |
// return 0; |
return 0; |
} |
/** |
/branches/fs/uspace/cat/cat.c |
---|
1,7 → 1,41 |
/* |
* Cat |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FSDemo |
* @{ |
*/ |
/** |
* @file cat.c |
* @brief A file system demonstration task - raw IPC version |
*/ |
#include <err.h> |
#include <stdio.h> |
#include <stdlib.h> |
/branches/fs/uspace/cat/cat.h |
---|
1,2 → 1,45 |
/* Cat.h */ |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
#ifndef _CAT_H |
#define _CAT_H |
/** @addtogroup FSDemo |
* @{ |
*/ |
/** |
* @file cat.standard.c |
* @brief A file system demonstration task header file |
*/ |
/** |
*} |
*/ |
#endif |
/branches/fs/uspace/fs/tree.txt |
---|
File deleted |
/branches/fs/uspace/fs/inode.c |
---|
32,22 → 32,18 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* This file manages the inode table. There are procedures to allocate and |
* deallocate inodes, acquire, erase, and release them, and read and write |
* them from the disk. |
/** |
* @file inode.c |
* @brief This file manages the inode table. There are procedures to allocate and |
* deallocate inodes, acquire, erase, and release them, and read and write |
* them from the disk. |
*/ |
/* Methods: |
* get_inode: search inode table for a given inode; if not there, read it |
* read_inode: read a disk block and extract an inode |
* v1_copy_inode copy from disk inode (V1.x) to in-memory inode struct |
* v2_copy_inode copy from disk inode (V2.x) to in-memory inode structs |
* put_inode indicate that an inode is no longer needed in memory |
* dup_inode: indicate that someone else is using an inode table entry |
*/ |
#include "fs.h" |
#include "block.h" |
#include "file.h" |
55,13 → 51,14 |
#include "inode.h" |
#include "super.h" |
inode_t inode[NR_INODES]; /**< A variable to store inode entries */ |
inode_t inode[NR_INODES]; |
static void v1_copy_inode(inode_t *rip, d1_inode_t *dip, int normal); |
static void v2_copy_inode(inode_t *rip, d2_inode_t *dip, int normal); |
/** |
* Search inode table for a given inode; if not there, read it |
*/ |
inode_t *get_inode(int numb) |
{ |
/* Find a slot in the inode table, load the specified inode into it, and |
100,6 → 97,9 |
return xp; |
} |
/** |
* Read a disk block and extract an inode |
*/ |
void read_inode(register inode_t *rip) |
{ |
128,11 → 128,12 |
v2_copy_inode(rip, dip2, sp->s_native); |
} |
} |
/** |
* Copy from disk inode (V1.x) to in-memory inode struct |
*/ |
void v1_copy_inode(inode_t *rip, d1_inode_t *dip, int normal) |
{ |
/* The V1.x IBM disk, the V1.x 68000 disk, and the V2 disk (same for IBM and |
* 68000) all have different inode layouts. When an inode is read or written |
* this routine handles the conversions so that the information in the inode |
156,11 → 157,12 |
for (i = 0; i < V1_NR_TZONES; i++) |
rip->i_zone[i] = conv2(normal, dip->d1_zone[i]); |
} |
/** |
* Copy from disk inode (V2.x) to in-memory inode structs |
*/ |
void v2_copy_inode(inode_t *rip, d2_inode_t *dip, int normal) |
{ |
/* Same as old_icopy, but to/from V2 disk layout. */ |
int i; |
180,6 → 182,9 |
rip->i_zone[i] = conv4(normal, dip->d2_zone[i]); |
} |
/** |
* Indicate that an inode is no longer needed in memory |
*/ |
void put_inode(inode_t *rip) |
{ |
190,7 → 195,10 |
rip->i_count--; |
} |
/** |
* Indicate that someone else is using an inode table entry |
*/ |
void dup_inode(inode_t *rip) |
{ |
204,3 → 212,8 |
rip->i_count++; |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/super.c |
---|
32,14 → 32,14 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* Superblock support. */ |
/* Methods: |
* init_super: initializes the superblock structure for later use |
* get_super: return pointer at the superblock |
* read_super: read a superblock |
/** |
* @file utility.c |
* @brief Superblock support. |
*/ |
#include <string.h> |
56,14 → 56,19 |
static int v2(int magic ,int*version, int *extend); |
static int get_native(int magic, int *version, int *extend); |
/** |
* File system versions |
*/ |
int (*versions[TOTAL_VERSIONS])(int , int*, int*) = { |
v1, /* 0 = V1 version */ |
v2 /* 1 = V2 version */ |
}; |
/** |
* Initializes the superblock structure for later use |
*/ |
int init_super_block() |
{ |
super_block = (super_block_t*)malloc(sizeof(super_block_t)); |
if (super_block != NULL) |
return TRUE; |
70,15 → 75,20 |
return FALSE; |
} |
/** |
* Return pointer at the superblock |
*/ |
super_block_t *get_super() |
{ |
return super_block; |
} |
/** |
* Read a superblock |
*/ |
int read_super(register super_block_t *sp) |
{ |
/* Read a superblock. */ |
register block_t *bp; |
140,6 → 150,9 |
return OK; |
} |
/** |
* Test the superblock against MINIX FS v1 |
*/ |
int v1(int magic, int* version, int *extend) |
{ |
156,6 → 169,9 |
return FALSE; |
} |
/** |
* Test the superblock against MINIX FS v2 |
*/ |
int v2(int magic, int *version, int *extend) |
{ |
172,10 → 188,11 |
return FALSE; |
} |
/** |
* Check the file system version and type |
*/ |
int get_native(int magic, int *version, int *extend) |
{ |
{ |
int i, result; |
/* Get file system version and type */ |
188,3 → 205,8 |
return FS_EINVAL; |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/block.h |
---|
32,8 → 32,15 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* Data block. */ |
/** |
* @file block.h |
* @brief Data block. |
*/ |
#ifndef _BLOCK_H |
#define _BLOCK_H |
40,24 → 47,32 |
#include "dir.h" |
#define DIRECTORY_BLOCK 1 /* directory block */ |
#define INDIRECT_BLOCK 2 /* pointer block */ |
#define DIRECTORY_BLOCK 1 /**< directory block */ |
#define INDIRECT_BLOCK 2 /**< pointer block */ |
/** |
* Data block |
*/ |
typedef struct { |
union { |
char b__data[BLOCK_SIZE]; /* ordinary user data */ |
direct_t b__dir[NR_DIR_ENTRIES]; /* directory block */ |
directex_t b__direx[NR_DIR_ENTRIES_EX]; /* extended directory block */ |
zone1_t b__v1_ind[V1_INDIRECTS]; /* V1 indirect block */ |
zone_t b__v2_ind[V2_INDIRECTS]; /* V2 indirect block */ |
d1_inode_t b__v1_ino[V1_INODES_PER_BLOCK]; /* V1 inode block */ |
d2_inode_t b__v2_ino[V2_INODES_PER_BLOCK]; /* V2 inode block */ |
char b__data[BLOCK_SIZE]; /**< ordinary user data */ |
direct_t b__dir[NR_DIR_ENTRIES]; /**< directory block */ |
directex_t b__direx[NR_DIR_ENTRIES_EX]; /**< extended directory block */ |
zone1_t b__v1_ind[V1_INDIRECTS]; /**< V1 indirect block */ |
zone_t b__v2_ind[V2_INDIRECTS]; /**< V2 indirect block */ |
d1_inode_t b__v1_ino[V1_INODES_PER_BLOCK]; /**< V1 inode block */ |
d2_inode_t b__v2_ino[V2_INODES_PER_BLOCK]; /**< V2 inode block */ |
} b; |
block_num_t b_blocknr; /* number of block */ |
char b_count; /* number of users of this block */ |
block_num_t b_blocknr; /**< number of block */ |
char b_count; /**< number of users of this block */ |
} block_t; |
extern block_t* work_block; |
#endif /* _BLOCK_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/open.c |
---|
32,17 → 32,16 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* This file contains the procedures for opening, closing, and seeking on files. */ |
/* Methods: |
* do_open: perform the OPEN system call |
* do_close: perform the CLOSE system call |
* do_lseek: perform the SEEK system call |
/** |
* @file open.c |
* @brief This file contains the procedures for opening, closing, and seeking on files. |
*/ |
#include "fs.h" |
#include "block.h" |
#include "file.h" |
50,7 → 49,9 |
#include "inode.h" |
#include "param.h" |
/** |
* Perform the OPEN system call |
*/ |
int do_open() |
{ |
82,6 → 83,9 |
return fd; |
} |
/** |
* Perform the CLOSE system call |
*/ |
int do_close() |
{ |
106,6 → 110,9 |
return OK; |
} |
/** |
* Perform the SEEK system call |
*/ |
int do_lseek() |
{ |
154,3 → 161,7 |
return pos; |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/inode.h |
---|
32,42 → 32,55 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file inode.h |
* @brief Inode table definition. |
*/ |
/* Inode table. This table holds inodes that are currently in use. In some |
* cases they have been opened by an open() or creat() system call, in other |
* cases the file system itself needs the inode for one reason or another, |
* such as to search a directory for a path name. |
* The first part of the struct holds fields that are present on the |
* disk; the second part holds fields not present on the disk. |
*/ |
#ifndef _INODE_H |
#define _INODE_H |
#include "super.h" |
#define NIL_INODE (inode_t *) 0 /* indicates absence of inode slot */ |
#define NIL_INODE (inode_t *) 0 /**< indicates absence of inode slot */ |
#define NO_SEEK 0 /* i_seek = NO_SEEK if last op was not SEEK */ |
#define ISEEK 1 /* i_seek = ISEEK if last op was SEEK */ |
#define NO_SEEK 0 /**< i_seek = NO_SEEK if last op was not SEEK */ |
#define ISEEK 1 /**< i_seek = ISEEK if last op was SEEK */ |
/* |
* This table holds inodes that are currently in use. In some |
* cases they have been opened by an open() or creat() system call, in other |
* cases the file system itself needs the inode for one reason or another, |
* such as to search a directory for a path name. |
* The first part of the struct holds fields that are present on the |
* disk; the second part holds fields not present on the disk. |
*/ |
typedef struct { |
mode_t i_mode; /* file type, protection, etc. */ |
nlink_t i_nlinks; /* how many links to this file */ |
offset_t i_size; /* current file size in bytes */ |
zone_t i_zone[V2_NR_TZONES]; /* zone numbers for direct, ind, and dbl ind */ |
mode_t i_mode; /**< file type, protection, etc. */ |
nlink_t i_nlinks; /**< how many links to this file */ |
offset_t i_size; /**< current file size in bytes */ |
zone_t i_zone[V2_NR_TZONES]; /**< zone numbers for direct, ind, and dbl ind */ |
/* The following items are not present on the disk. */ |
dev_t i_dev; /* which device is the inode on */ |
ino_t i_num; /* inode number on its (minor) device */ |
int i_count; /* # times inode used; 0 means slot is free */ |
int i_ndzones; /* # direct zones (NR_DZONES) */ |
int i_nindirs; /* # indirect zones per indirect block */ |
super_block_t *i_sp; /* pointer to super block for inode's device */ |
char i_seek; /* set on LSEEK, cleared on READ */ |
dev_t i_dev; /**< which device is the inode on */ |
ino_t i_num; /**< inode number on its (minor) device */ |
int i_count; /**< # times inode used; 0 means slot is free */ |
int i_ndzones; /**< # direct zones (NR_DZONES) */ |
int i_nindirs; /**< # indirect zones per indirect block */ |
super_block_t *i_sp; /**< pointer to super block for inode's device */ |
char i_seek; /**< set on LSEEK, cleared on READ */ |
} inode_t; |
extern inode_t inode[NR_INODES]; |
#endif /* _INODE_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/super.h |
---|
32,23 → 32,18 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* |
* The s_ninodes field gives the number of inodes available |
* for files and directories, including the root directory. Inode 0 is |
* on the disk, but not used. Thus s_ninodes = 4 means that 5 bits will be |
* used in the bit map, bit 0, which is always 1 and not used, and bits 1-4 |
* for files and directories. The disk layout is: |
* |
* Item # blocks |
* boot block 1 |
* super block 1 |
* inode map s_imap_blocks |
* zone map s_zmap_blocks |
* inodes (s_ninodes + 'inodes per block' - 1)/'inodes per block' |
* unused whatever is needed to fill out the current zone |
* data zones (s_zones - s_firstdatazone) << s_log_zone_size |
/** |
* @file super.h |
* @brief The s_ninodes field gives the number of inodes available |
* for files and directories, including the root directory. Inode 0 is |
* on the disk, but not used. Thus s_ninodes = 4 means that 5 bits will be |
* used in the bit map, bit 0, which is always 1 and not used, and bits 1-4 |
* for files and directories. |
* |
*/ |
56,31 → 51,48 |
#ifndef _SUPER_H |
#define _SUPER_H |
#define NIL_SUPER (super_block_t *) 0 |
#define NIL_SUPER (super_block_t *) 0 /**< An empty super block */ |
/** |
* The disk layout is: |
* |
* Item # blocks |
* boot block 1 |
* super block 1 |
* inode map s_imap_blocks |
* zone map s_zmap_blocks |
* inodes (s_ninodes + 'inodes per block' - 1)/'inodes per block' |
* unused whatever is needed to fill out the current zone |
* data zones (s_zones - s_firstdatazone) << s_log_zone_size |
*/ |
typedef struct { |
ino_t s_ninodes; /* # usable inodes on the minor device */ |
zone1_t s_nzones; /* total device size, including bit maps etc */ |
short s_imap_blocks; /* # of blocks used by inode bit map */ |
short s_zmap_blocks; /* # of blocks used by zone bit map */ |
zone1_t s_firstdatazone; /* number of first data zone */ |
short s_log_zone_size; /* log2 of blocks/zone */ |
offset_t s_max_size; /* maximum file size on this device */ |
short s_magic; /* magic number to recognize super-blocks */ |
short s_pad; /* try to avoid compiler-dependent padding */ |
zone_t s_zones; /* number of zones (replaces s_nzones in V2) */ |
ino_t s_ninodes; /**< # usable inodes on the minor device */ |
zone1_t s_nzones; /**< total device size, including bit maps etc */ |
short s_imap_blocks; /**< # of blocks used by inode bit map */ |
short s_zmap_blocks; /**< # of blocks used by zone bit map */ |
zone1_t s_firstdatazone; /**< number of first data zone */ |
short s_log_zone_size; /**< log2 of blocks/zone */ |
offset_t s_max_size; /**< maximum file size on this device */ |
short s_magic; /**< magic number to recognize super-blocks */ |
short s_pad; /**< try to avoid compiler-dependent padding */ |
zone_t s_zones; /**< number of zones (replaces s_nzones in V2) */ |
/* The following items are only used when the super_block is in memory. */ |
unsigned s_inodes_per_block; /* precalculated from magic number */ |
int s_native; /* set to 1 iff not byte swapped file system */ |
int s_version; /* file system version, zero means bad magic */ |
int s_extend; /* 1 if file system support 30 chars in file name */ |
int s_ndzones; /* # direct zones in an inode */ |
int s_nindirs; /* # indirect zones per indirect block */ |
bit_t s_isearch; /* inodes below this bit number are in use */ |
bit_t s_zsearch; /* all zones below this bit number are in use*/ |
unsigned s_inodes_per_block; /**< precalculated from magic number */ |
int s_native; /**< set to 1 iff not byte swapped file system */ |
int s_version; /**< file system version, zero means bad magic */ |
int s_extend; /**< 1 if file system support 30 chars in file name */ |
int s_ndzones; /**< # direct zones in an inode */ |
int s_nindirs; /**< # indirect zones per indirect block */ |
bit_t s_isearch; /**< inodes below this bit number are in use */ |
bit_t s_zsearch; /**< all zones below this bit number are in use*/ |
} super_block_t; |
extern super_block_t* super_block; |
extern super_block_t* super_block; /**< A variable to store the super block */ |
#endif /* _SUPER_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/utility.c |
---|
32,19 → 32,20 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file utility.c |
* @brief This is the master header for fs. It includes some other files |
* and defines the principal constants. |
*/ |
/* This file contains a few general purpose utility routines. */ |
/* Methods: |
* fetch_name: go get a path name from user space |
* no_sys: reject a system call that FS does not handle |
* conv2: does byte swapping on a 16-bit int |
* conv4: does byte swapping on a 32-bit long |
* fs_strncmp: same like strncmp |
*/ |
#include <unistd.h> |
#include "fs.h" |
#include "block.h" |
52,7 → 53,9 |
#include "fproc.h" |
#include "inode.h" |
/** |
* Go get a path name from user space |
*/ |
int fetch_name(char* path, int len) |
{ |
78,7 → 81,10 |
return OK; |
} |
/** |
* Reject a system call that FS does not handle |
*/ |
int no_sys() |
{ |
86,9 → 92,12 |
print_console("FS_NOSYS called, illegal system call number!\n"); |
return FS_EINVAL; |
re\turn FS_EINVAL; |
} |
/** |
* Does byte swapping on a 16-bit int |
*/ |
unsigned conv2(int norm, int w) |
{ |
100,6 → 109,9 |
return(((w&BYTE) << 8) | ( (w>>8) & BYTE)); |
} |
/** |
* Does byte swapping on a 32-bit long |
*/ |
long conv4(int norm, long x) |
{ |
118,6 → 130,9 |
return l; |
} |
/** |
* Same like strncmp |
*/ |
int fs_strncmp(const char *src, const char *dst, size_t len) |
{ |
144,3 → 159,8 |
return 0; |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/param.h |
---|
1,6 → 1,40 |
/* Synonym names for message parameters. */ |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemTask |
* @{ |
*/ |
/** |
* @file param.h |
* @brief Synonym names for message parameters. |
*/ |
#ifndef _PARAM_H |
#define _PARAM_H |
14,3 → 48,8 |
#define entry_number message_params.entry_number |
#endif /* _PARAM_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/limits.h |
---|
32,19 → 32,29 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file limits.h |
* @brief Constants which define limits of file system capabilities. |
*/ |
/* Constants which define limits of file system capabilities. */ |
#ifndef _LIMITS_H_ |
#define _LIMITS_H_ |
/* Number of slots in the process table for user processes. */ |
#define NR_PROCS 20 |
#define NR_PROCS 20 /**< Number of slots in the process table for user processes. */ |
#define NAME_MAX 14 /* #chars in file name */ |
#define NAME_MAX_EX 30 /* #chars in file name - extended versions */ |
#define PATH_MAX 255 /* #chars in path name */ |
#define OPEN_MAX 20 /* open files a process may have */ |
#define NAME_MAX 14 /**< #chars in file name */ |
#define NAME_MAX_EX 30 /**< #chars in file name - extended versions */ |
#define PATH_MAX 255 /**< #chars in path name */ |
#define OPEN_MAX 20 /**< open files a process may have */ |
#endif /* _LIMITS_H_ */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/fs.c |
---|
1,5 → 1,5 |
/* |
* Copyright (c) 2006 Martin Decky |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
26,7 → 26,7 |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup fs |
/** @addtogroup FileSystemTask |
* @{ |
*/ |
54,15 → 54,18 |
static int fs_call; |
static ipc_call_t m_input; /* the input message used for request */ |
static ipc_callid_t callid; /* caller's number */ |
static int new_consument; /* if new consumer wants to connect to FS */ |
static int check_con; /* check of connection of consument */ |
static ipc_call_t m_input; /**< the input message used for request */ |
static ipc_callid_t callid; /**< caller's number */ |
static int new_consument; /**< if new consumer wants to connect to FS */ |
static int check_con; /**< check of connection of consument */ |
static void prepare_message(void); |
static int load_super(void); |
static int new_consument_map(void); |
/** |
* Respond to incoming requests from user tasks |
*/ |
static void fs_connection(ipc_callid_t iid, ipc_call_t *icall) |
{ |
132,7 → 135,9 |
} |
} |
/* Extracts parameters from message and prepare them for later usage. */ |
/** |
* Extracts parameters from message and prepare them for later usage. |
*/ |
void prepare_message(void) |
{ |
188,7 → 193,9 |
unpack_message(&message_params, m_input, fp->buffer); |
} |
/* Map some memory to the task */ |
/** |
* Map some memory to the task |
*/ |
int new_consument_map() |
{ |
225,7 → 232,9 |
return TRUE; |
} |
/* Basic initialization. */ |
/** |
* Basic initialization. |
*/ |
static bool fs_init(void) |
{ |
295,6 → 304,10 |
return TRUE; |
} |
/** |
* The initialization method for the FS task, it connects to the RD service |
* and then starts the asynchronous request listener for this task. |
*/ |
int main(int argc, char **argv) |
{ |
/branches/fs/uspace/fs/proto.h |
---|
32,11 → 32,17 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file proto.h |
* @brief Function prototypes for the File System implementation. |
*/ |
/* Function prototypes. */ |
#ifndef _PROTO_H |
#define _PROTO_H |
111,3 → 117,8 |
#endif /* _PROTO_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/filedes.c |
---|
32,24 → 32,24 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* This file contains the procedures that manipulate file descriptors. */ |
/* |
* Methods: |
* get_fd: look for free file descriptor and free filp slots |
* get_filp: look up the filp entry for a given file descriptor |
* find_filp: find a filp slot that points to a given inode |
/** |
* @file filedesc.c |
* @brief This file contains the procedures that manipulate file descriptors. |
*/ |
#include "fs.h" |
#include "file.h" |
#include "fproc.h" |
#include "inode.h" |
/** |
* Look for free file descriptor and free filp slots |
*/ |
int get_fd(int start, int *k, filp_t **fpt) |
{ |
/* Look for a free file descriptor and a free filp slot. */ |
87,7 → 87,9 |
return FS_ENFILE; |
} |
/** |
* Look up the filp entry for a given file descriptor |
*/ |
filp_t *get_filp(int fild) |
{ |
101,6 → 103,9 |
} |
/** |
* Find a filp slot that points to a given inode |
*/ |
filp_t *find_filp(register inode_t *rip) |
{ |
121,3 → 126,8 |
return NIL_FILP; |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/read.c |
---|
32,19 → 32,18 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* This file contains the heart of the mechanism used to read files. |
* Read requests are split up into chunks that do not cross block |
* boundaries. Each chunk is then processed in turn. |
/** |
* @file read.c |
* @brief This file contains the heart of the mechanism used to read files. |
* Read requests are split up into chunks that do not cross block |
* boundaries. Each chunk is then processed in turn. |
*/ |
/* Methods: |
* do_read: perform the READ system call |
* read_map: given an inode and file position, look up its zone number |
* rd_indir: read an entry in an indirect block |
*/ |
#include <stdio.h> |
#include "fs.h" |
#include "block.h" |
58,6 → 57,9 |
static int read_chunk(inode_t *rip, offset_t position, |
unsigned off, int chunk, char *buff); |
/** |
* Perform the READ system call |
*/ |
int do_read() |
{ |
161,7 → 163,10 |
return r; |
} |
} |
/** |
* Given an inode and file position, look up its zone number |
*/ |
static int read_chunk(register inode_t *rip, offset_t position, unsigned off, |
int chunk, char *buff) |
{ |
194,7 → 199,10 |
return OK; |
} |
/** |
* Read an entry in an indirect block |
*/ |
block_num_t read_map(register inode_t *rip, offset_t position) |
{ |
262,6 → 270,9 |
return b; |
} |
/** |
* |
*/ |
zone_t rd_indir(block_t *bp, int index) |
{ |
285,3 → 296,8 |
return zone; |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/fs.h |
---|
1,5 → 1,39 |
/* This is the master header for fs. It includes some other files |
* and defines the principal constants. |
/* |
* Copyright (c) 2007 Konopa-Jelen-Majer |
* All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions |
* are met: |
* |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above copyright |
* notice, this list of conditions and the following disclaimer in the |
* documentation and/or other materials provided with the distribution. |
* - The name of the author may not be used to endorse or promote products |
* derived from this software without specific prior written permission. |
* |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemTask |
* @{ |
*/ |
/** |
* @file fs.h |
* @brief This is the master header for fs. It includes some other files |
* and defines the principal constants. |
*/ |
#ifndef _FS_H |
/branches/fs/uspace/fs/fproc.h |
---|
32,9 → 32,14 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* This is the per-process information. A slot is reserved for each potential |
* process. |
/** |
* @file fproc.h |
* @brief Per-process information definition |
*/ |
41,14 → 46,17 |
#ifndef _FPROC_H |
#define _FPROC_H |
/** |
* This is the per-process information. A slot is reserved for each potential process. |
*/ |
typedef struct { |
inode_t *fp_workdir; /* pointer to working directory's inode */ |
inode_t *fp_rootdir; /* pointer to current root dir (see chroot) */ |
filp_t *fp_filp[OPEN_MAX];/* the file descriptor table */ |
int fp_cum_io_partial; /* partial byte count if read can't finish */ |
pid_t fp_pid; /* process id */ |
int connected; /* is connection valid? */ |
void *buffer; /* buffer for data */ |
inode_t *fp_workdir; /**< pointer to working directory's inode */ |
inode_t *fp_rootdir; /**< pointer to current root dir (see chroot) */ |
filp_t *fp_filp[OPEN_MAX];/**< the file descriptor table */ |
int fp_cum_io_partial; /**< partial byte count if read can't finish */ |
pid_t fp_pid; /**< process id */ |
int connected; /**< is connection valid? */ |
void *buffer; /**< buffer for data */ |
} fproc_t; |
extern fproc_t fproc[NR_PROCS]; |
55,3 → 63,8 |
#endif /* _FPROC_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/dir.c |
---|
1,10 → 1,46 |
/* This file contains the procedures for support directory operations. */ |
/* |
* Copyright (c) 1987,1997, Prentice Hall |
* All rights reserved. |
* |
* Redistribution and use of the MINIX operating system in source and |
* binary forms, with or without modification, are permitted provided |
* that the following conditions are met: |
/* Methods: |
* do_sum: return total number of directory entries |
* do_readentry: fill in the user buffer with directory entry specified by number |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above |
* copyright notice, this list of conditions and the following |
* disclaimer in the documentation and/or other materials provided |
* with the distribution. |
* - Neither the name of Prentice Hall nor the names of the software |
* authors or contributors may be used to endorse or promote |
* products derived from this software without specific prior |
* written permission. |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND |
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file dir.c |
* @brief This file contains the procedures for support directory operations. |
*/ |
#include <stdio.h> |
#include "fs.h" |
13,7 → 49,9 |
#include "inode.h" |
#include "param.h" |
/** |
* Return total number of directory entries |
*/ |
int do_sum() |
{ |
40,7 → 78,9 |
return dir_count; |
} |
/** |
* Fill in the user buffer with directory entry specified by number |
*/ |
int do_readentry() |
{ |
93,3 → 133,7 |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/stat.h |
---|
1,4 → 1,4 |
/* |
/*/* |
* Copyright (c) 1987,1997, Prentice Hall |
* All rights reserved. |
* |
32,11 → 32,14 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* Definition of a struct that is used in the stat and fstat calls. |
* The information in this struct comes from the i-node of some file. |
* These calls are the only approved way to inspect i-nodes. |
/** |
* @file stat.h |
* @brief Definition of a struct that is used in the stat and fstat calls. |
*/ |
43,11 → 46,19 |
#ifndef _STAT_H |
#define _STAT_H |
/** The information in this struct comes from the i-node of some file. |
* These calls are the only approved way to inspect i-nodes. |
*/ |
typedef struct { |
ino_t st_ino; /* i-node number */ |
mode_t st_mode; /* file mode, protection bits, etc. */ |
short int st_nlink; /* # links; TEMPORARY HACK: should be nlink_t*/ |
offset_t st_size; /* file size */ |
ino_t st_ino; /**< i-node number */ |
mode_t st_mode; /**< file mode, protection bits, etc. */ |
short int st_nlink; /**< # links; TEMPORARY HACK: should be nlink_t*/ |
offset_t st_size; /**< file size */ |
} stat_t; |
#endif /* _STAT_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/glo.c |
---|
32,11 → 32,17 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file glo.c |
* @brief File System global variables. |
*/ |
/* Global variables declaring. */ |
#include "fs.h" |
#include "file.h" |
#include "fproc.h" |
44,21 → 50,25 |
#include "../share/message.h" |
/* File System global variables. */ |
fproc_t *fp; /* pointer to caller's fproc struct */ |
fproc_t fproc[NR_PROCS]; /* per process information table */ |
filp_t filp[NR_FILPS]; /* filp table */ |
fproc_t *fp; /**< pointer to caller's fproc struct */ |
fproc_t fproc[NR_PROCS]; /**< per process information table */ |
filp_t filp[NR_FILPS]; /**< filp table */ |
/* The parameters of the call are kept here. */ |
message_params_t message_params; /* parameters of the input message */ |
int rd_phone; /* call number of RAMDISK driver task */ |
int con_phone; /* call number of CONSOLE service */ |
char user_path[PATH_MAX]; /* storage for user path name */ |
message_params_t message_params; /**< parameters of the input message */ |
int rd_phone; /**< call number of RAMDISK driver task */ |
int con_phone; /**< call number of CONSOLE service */ |
char user_path[PATH_MAX]; /**< storage for user path name */ |
/* Data needed for communication with RAMDISK. */ |
void *buffer; /* buffer for storing data retrieved from RAMDISK */ |
void *buffer; /**< buffer for storing data retrieved from RAMDISK */ |
/* The following variables are used for returning results to the caller. */ |
int err_code; /* temporary storage for error number */ |
int status; /* status of last disk i/o request */ |
int err_code; /**< temporary storage for error number */ |
int status; /**< status of last disk i/o request */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/dir.h |
---|
32,32 → 32,48 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file dir.h |
* @brief The layout of a directory. |
*/ |
/* The layout of a directory. */ |
#ifndef _DIR_H |
#define _DIR_H |
#define DIRBLKSIZ 512 /* size of directory block */ |
#define DIRSIZ 14 |
#define DIRSIZEX 30 |
#define DIRBLKSIZ 512 /**< size of directory block */ |
#define DIRSIZ 14 /**< directory entry name length */ |
#define DIRSIZEX 30 /**< extended directory entry name length */ |
#include "inode.h" |
/** |
* Directory entry type |
*/ |
typedef struct { |
ino_t d_ino; |
char d_name[DIRSIZ]; |
} direct_t; |
/** |
* Extended directory entry type |
*/ |
typedef struct { |
ino_t d_ino; |
char d_name[DIRSIZEX]; |
} directex_t; |
direct_t direct; |
directex_t directex; |
direct_t direct; /**< Variable for storing a directory entry */ |
directex_t directex; /**< Variable for storing an extended directory entry */ |
#endif /* _DIR_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/file.h |
---|
32,26 → 32,38 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* This is the filp table. It is an intermediary between file descriptors and |
* inodes. A slot is free if filp_count == 0. |
*/ |
/** |
* @file file.h |
* @brief Filp table definition |
*/ |
#ifndef _FILE_H |
#define _FILE_H |
/** |
* This is the filp table. It is an intermediary between file descriptors and |
* inodes. A slot is free if filp_count == 0. |
*/ |
typedef struct { |
mode_t filp_mode; /* RW bits, telling how file is opened */ |
int filp_flags; /* flags from open and fcntl */ |
int filp_count; /* how many file descriptors share this slot?*/ |
inode_t *filp_ino; /* pointer to the inode */ |
offset_t filp_pos; /* file position */ |
mode_t filp_mode; /**< RW bits, telling how file is opened */ |
int filp_flags; /**< flags from open and fcntl */ |
int filp_count; /**< how many file descriptors share this slot?*/ |
inode_t *filp_ino; /**< pointer to the inode */ |
offset_t filp_pos; /**< file position */ |
} filp_t; |
extern filp_t filp[NR_FILPS]; |
#define FILP_CLOSED 0 /* filp_mode: associated device closed */ |
#define NIL_FILP (filp_t *) 0 /* indicates absence of a filp slot */ |
#define FILP_CLOSED 0 /**< filp_mode: associated device closed */ |
#define NIL_FILP (filp_t *) 0 /**< indicates absence of a filp slot */ |
#endif /* _FILE_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/glo.h |
---|
32,8 → 32,15 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* Global variables */ |
/** |
* @file glo.h |
* @brief Global variables |
*/ |
#ifndef _GLO_H |
43,22 → 50,27 |
#include "../share/message.h" |
/* File System global variables. */ |
extern fproc_t *fp; /* pointer to caller's fproc struct */ |
extern fproc_t *fp; /**< pointer to caller's fproc struct */ |
/* The parameters of the call are kept here. */ |
extern message_params_t message_params; /* parameters of the input message */ |
extern int rd_phone; /* call number of RAMDISK driver task */ |
extern int con_phone; /* call number of CONSOLE service */ |
extern char user_path[PATH_MAX]; /* storage for user path name */ |
extern message_params_t message_params; /**< parameters of the input message */ |
extern int rd_phone; /**< call number of RAMDISK driver task */ |
extern int con_phone; /**< call number of CONSOLE service */ |
extern char user_path[PATH_MAX]; /**< storage for user path name */ |
/* Data needed for communication with RAMDISK. */ |
extern void *buffer; /* buffer storing copied data */ |
extern void *buffer; /**< buffer storing copied data */ |
/* The following variables are used for returning results to the caller */ |
extern int err_code; /* temporary storage for error number */ |
extern int status; /* status of last disk i/o request */ |
extern int err_code; /**< temporary storage for error number */ |
extern int status; /**< status of last disk i/o request */ |
/* Data which need initialization. */ |
extern int (*call_vector[])(void); /* sys call table */ |
extern int (*call_vector[])(void); /**< sys call table */ |
#endif /* _GLO_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/stadir.c |
---|
32,19 → 32,18 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* This file contains the code for performing four system calls relating to |
* status and directories. |
/** |
* @file stadir.c |
* @brief This file contains the code for performing four system calls relating to |
* status and directories. |
*/ |
/* Methods: |
* do_chdir: perform the CHDIR system call |
* do_stat: perform the STAT system call |
* do_fstat: perform the FSTAT system call |
*/ |
#include "fs.h" |
#include "stat.h" |
#include "file.h" |
55,7 → 54,10 |
static int change(inode_t **iip, char *name_ptr, int len); |
static int stat_inode(inode_t *rip, filp_t *fil_ptr, char *user_addr); |
/** |
* Perform the CHDIR system call |
*/ |
int do_chdir() |
{ |
66,7 → 68,10 |
return r; |
} |
/** |
* Execute changing the current directory |
*/ |
int change(inode_t **iip, char *name_ptr, int len) |
{ |
106,7 → 111,10 |
return OK; |
} |
/** |
* Perform the STAT system call |
*/ |
int do_stat() |
{ |
130,7 → 138,10 |
return r; |
} |
/** |
* Perform the FSTAT system call |
*/ |
int do_fstat() |
{ |
148,7 → 159,10 |
return(stat_inode(rfilp->filp_ino, NIL_FILP, fp->buffer)); |
} |
/** |
* Execute the actual STAT operation |
*/ |
int stat_inode(register inode_t *rip, filp_t *fil_ptr, char *user_addr) |
{ |
174,3 → 188,8 |
return OK; |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/type.h |
---|
32,10 → 32,15 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* Declaration of the basic used types which are part of the V1 and V2 inode |
* as it is on the disk (not in memory). |
/** |
* @file type.h |
* @brief Declaration of the basic used types which are part of the V1 and V2 inode |
* as it is on the disk (not in memory). |
*/ |
45,54 → 50,63 |
#include <sys/time.h> |
/* Types used in disk, inode, etc. data structures. */ |
typedef unsigned short mode_t; /* file type and permissions bits */ |
typedef char nlink_t; /* number of links to a file */ |
typedef short dev_t; /* holds (major|minor) device pair */ |
typedef char gid_t; /* group id */ |
typedef unsigned short ino_t; /* i-node number */ |
typedef unsigned long offset_t; /* offset within a file */ |
typedef int pid_t; /* process id (must be signed) */ |
typedef short uid_t; /* user id */ |
typedef unsigned long zone_t; /* zone number */ |
typedef unsigned short zone1_t; /* zone number for V1 file systems */ |
typedef unsigned long block_num_t; /* block number */ |
typedef unsigned long bit_t; /* bit number in a bit map */ |
typedef unsigned short bitchunk_t; /* collection of bits in a bitmap */ |
typedef unsigned short mode_t; /**< file type and permissions bits */ |
typedef char nlink_t; /**< number of links to a file */ |
typedef short dev_t; /**< holds (major|minor) device pair */ |
typedef char gid_t; /**< group id */ |
typedef unsigned short ino_t; /**< i-node number */ |
typedef unsigned long offset_t; /**< offset within a file */ |
typedef int pid_t; /**< process id (must be signed) */ |
typedef short uid_t; /**< user id */ |
typedef unsigned long zone_t; /**< zone number */ |
typedef unsigned short zone1_t; /**< zone number for V1 file systems */ |
typedef unsigned long block_num_t; /**< block number */ |
typedef unsigned long bit_t; /**< bit number in a bit map */ |
typedef unsigned short bitchunk_t; /**< collection of bits in a bitmap */ |
typedef unsigned char u8_t; /* 8 bit type */ |
typedef unsigned short u16_t; /* 16 bit type */ |
typedef unsigned long u32_t; /* 32 bit type */ |
typedef unsigned char u8_t; /**< 8 bit type */ |
typedef unsigned short u16_t; /**< 16 bit type */ |
typedef unsigned long u32_t; /**< 32 bit type */ |
typedef char i8_t; /* 8 bit signed type */ |
typedef short i16_t; /* 16 bit signed type */ |
typedef long i32_t; /* 32 bit signed type */ |
typedef char i8_t; /**< 8 bit signed type */ |
typedef short i16_t; /**< 16 bit signed type */ |
typedef long i32_t; /**< 32 bit signed type */ |
//typedef unsigned long phys_bytes;/* physical addresses and lengths in bytes */ |
/* Declaration of the V1 inode as it is on the disk (not in core). */ |
typedef struct { /* V1.x disk inode */ |
mode_t d1_mode; /* file type, protection, etc. */ |
uid_t d1_uid; /* user id of the file's owner */ |
offset_t d1_size; /* current file size in bytes */ |
time_t d1_mtime; /* when was file data last changed */ |
gid_t d1_gid; /* group number */ |
nlink_t d1_nlinks; /* how many links to this file */ |
zone1_t d1_zone[V1_NR_TZONES]; /* block nums for direct, ind, and dbl ind */ |
/** |
* Declaration of the V1 inode as it is on the disk (not in core). |
*/ |
typedef struct { /**< V1.x disk inode */ |
mode_t d1_mode; /**< file type, protection, etc. */ |
uid_t d1_uid; /**< user id of the file's owner */ |
offset_t d1_size; /**< current file size in bytes */ |
time_t d1_mtime; /**< when was file data last changed */ |
gid_t d1_gid; /**< group number */ |
nlink_t d1_nlinks; /**< how many links to this file */ |
zone1_t d1_zone[V1_NR_TZONES]; /**< block nums for direct, ind, and dbl ind */ |
} d1_inode_t; |
/* Declaration of the V2 inode as it is on the disk (not in core). */ |
typedef struct { /* V2.x disk inode */ |
mode_t d2_mode; /* file type, protection, etc. */ |
u16_t d2_nlinks; /* how many links to this file. HACK! */ |
uid_t d2_uid; /* user id of the file's owner. */ |
u16_t d2_gid; /* group number HACK! */ |
offset_t d2_size; /* current file size in bytes */ |
time_t d2_atime; /* when was file data last accessed */ |
time_t d2_mtime; /* when was file data last changed */ |
time_t d2_ctime; /* when was inode data last changed */ |
zone_t d2_zone[V2_NR_TZONES]; /* block nums for direct, ind, and dbl ind */ |
/** |
* Declaration of the V2 inode as it is on the disk (not in core). |
*/ |
typedef struct { /**< V2.x disk inode */ |
mode_t d2_mode; /**< file type, protection, etc. */ |
u16_t d2_nlinks; /**< how many links to this file. HACK! */ |
uid_t d2_uid; /**< user id of the file's owner. */ |
u16_t d2_gid; /**< group number HACK! */ |
offset_t d2_size; /**< current file size in bytes */ |
time_t d2_atime; /**< when was file data last accessed */ |
time_t d2_mtime; /**< when was file data last changed */ |
time_t d2_ctime; /**< when was inode data last changed */ |
zone_t d2_zone[V2_NR_TZONES]; /**< block nums for direct, ind, and dbl ind */ |
} d2_inode_t; |
#endif /* _TYPE_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/table.c |
---|
32,10 → 32,15 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* This file contains the table used to map system call numbers onto the |
* routines that perform them. |
/** |
* @file table.c |
* @brief This file contains the table used to map system call numbers onto the |
* routines that perform them. |
*/ |
#include "fs.h" |
44,6 → 49,9 |
#include "inode.h" |
#include "super.h" |
/** |
* The call table for all FS task methods |
*/ |
int (*call_vector[FS_CALLS])(void) = { |
no_sys, /* 0 = unused */ |
do_open, /* 1 = open */ |
57,3 → 65,8 |
do_readentry /* 9 = readentry */ |
}; |
/** |
* } |
*/ |
/branches/fs/uspace/fs/errno.h |
---|
1,24 → 1,71 |
/* Error codes */ |
/* |
* Copyright (c) 1987,1997, Prentice Hall |
* All rights reserved. |
* |
* Redistribution and use of the MINIX operating system in source and |
* binary forms, with or without modification, are permitted provided |
* that the following conditions are met: |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above |
* copyright notice, this list of conditions and the following |
* disclaimer in the documentation and/or other materials provided |
* with the distribution. |
* - Neither the name of Prentice Hall nor the names of the software |
* authors or contributors may be used to endorse or promote |
* products derived from this software without specific prior |
* written permission. |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND |
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file errno.h |
* @brief Error codes |
*/ |
#ifndef _ERRNO_H |
#define _ERRNO_H |
/* 256-512 are user error codes */ |
#define FS_ERROR_BASE -256 /* Base for FS error codes */ |
#define FS_ENOENT (FS_ERROR_BASE-1) /* no such file or directory */ |
#define FS_EIO (FS_ERROR_BASE-2) /* input/output error */ |
#define FS_EBADF (FS_ERROR_BASE-3) /* bad file descriptor */ |
#define FS_ENOTDIR (FS_ERROR_BASE-4) /* not a directory */ |
#define FS_EINVAL (FS_ERROR_BASE-5) /* invalid argument */ |
#define FS_ENFILE (FS_ERROR_BASE-6) /* too many open files in system */ |
#define FS_EMFILE (FS_ERROR_BASE-7) /* too many open files */ |
#define FS_EFBIG (FS_ERROR_BASE-8) /* file too large */ |
#define FS_ENAMETOOLONG (FS_ERROR_BASE-9) /* file name too long */ |
#define FS_ENOTEMPTY (FS_ERROR_BASE-10) /* directory not empty */ |
#define FS_EBADCALL (FS_ERROR_BASE-11) /* out of range of filesystem's call */ |
#define FS_EGENERIC (FS_ERROR_BASE-12) /* other error */ |
#define FS_ECONNECT (FS_ERROR_BASE-13) /* new consument initiating connection error */ |
#define FS_ENOTCONNECT (FS_ERROR_BASE-14) /* disconnected consument tried to call some function */ |
#define FS_ERROR_BASE -256 /**< Base for FS error codes */ |
#define FS_ENOENT (FS_ERROR_BASE-1) /**< no such file or directory */ |
#define FS_EIO (FS_ERROR_BASE-2) /**< input/output error */ |
#define FS_EBADF (FS_ERROR_BASE-3) /**< bad file descriptor */ |
#define FS_ENOTDIR (FS_ERROR_BASE-4) /**< not a directory */ |
#define FS_EINVAL (FS_ERROR_BASE-5) /**< invalid argument */ |
#define FS_ENFILE (FS_ERROR_BASE-6) /**< too many open files in system */ |
#define FS_EMFILE (FS_ERROR_BASE-7) /**< too many open files */ |
#define FS_EFBIG (FS_ERROR_BASE-8) /**< file too large */ |
#define FS_ENAMETOOLONG (FS_ERROR_BASE-9) /**< file name too long */ |
#define FS_ENOTEMPTY (FS_ERROR_BASE-10) /**< directory not empty */ |
#define FS_EBADCALL (FS_ERROR_BASE-11) /**< out of range of filesystem's call */ |
#define FS_EGENERIC (FS_ERROR_BASE-12) /**< other error */ |
#define FS_ECONNECT (FS_ERROR_BASE-13) /**< new consument initiating connection error */ |
#define FS_ENOTCONNECT (FS_ERROR_BASE-14) /**< disconnected consument tried to call some function */ |
#endif /* _ERRNO_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/block.c |
---|
1,11 → 1,46 |
/* Basic methods for reading blocks. */ |
/* |
* Copyright (c) 1987,1997, Prentice Hall |
* All rights reserved. |
* |
* Redistribution and use of the MINIX operating system in source and |
* binary forms, with or without modification, are permitted provided |
* that the following conditions are met: |
/* Methods: |
* init_block: Allocates memory for working block |
* get_block: Returns requested block according its number |
* read_block: Process reading of requested block |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
* - Redistributions in binary form must reproduce the above |
* copyright notice, this list of conditions and the following |
* disclaimer in the documentation and/or other materials provided |
* with the distribution. |
* - Neither the name of Prentice Hall nor the names of the software |
* authors or contributors may be used to endorse or promote |
* products derived from this software without specific prior |
* written permission. |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND |
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file block.c |
* @brief Basic methods for reading blocks. |
*/ |
#include <stdio.h> |
#include <async.h> |
15,9 → 50,11 |
#include "super.h" |
#include "../rd/rd.h" |
block_t* work_block; /**< A temporary variable for storing the working block */ |
block_t* work_block; |
/** |
* Allocates memory for working block |
*/ |
int init_block() |
{ |
29,6 → 66,9 |
return FALSE; |
} |
/** |
* Returns requested block according its number |
*/ |
block_t *get_block(register block_num_t block_nr) |
{ |
41,6 → 81,9 |
return work_block; |
} |
/** |
* Return a block filled with zeroes |
*/ |
block_t *get_zero_block() |
{ |
50,6 → 93,9 |
return work_block; |
} |
/** |
* Process reading of requested block |
*/ |
void read_block(register block_t *bp) |
{ |
74,3 → 120,7 |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/printing.c |
---|
1,13 → 1,48 |
/* Functions for printing on console. */ |
/* |
* Copyright (c) 1987,1997, Prentice Hall |
* All rights reserved. |
* |
* Redistribution and use of the MINIX operating system in source and |
* binary forms, with or without modification, are permitted provided |
* that the following conditions are met: |
* - Redistributions of source code must retain the above copyright |
* notice, this list of conditions and the following disclaimer. |
/* Methods: |
* init_printing: connects to SERVICE_CONSOLE and initializes used data structures |
* print_console: prints char* on console |
* print_console_int: prints int argument with specified conversion inside input string |
* - Redistributions in binary form must reproduce the above |
* copyright notice, this list of conditions and the following |
* disclaimer in the documentation and/or other materials provided |
* with the distribution. |
* - Neither the name of Prentice Hall nor the names of the software |
* authors or contributors may be used to endorse or promote |
* products derived from this software without specific prior |
* written permission. |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS, AUTHORS, AND |
* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, |
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
* IN NO EVENT SHALL PRENTICE HALL OR ANY AUTHORS OR CONTRIBUTORS BE |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file printing.c |
* @brief Functions for printing on console. |
*/ |
#include <string.h> |
#include <ipc/ipc.h> |
#include <ipc/services.h> |
19,12 → 54,17 |
#define BUFF_SIZE 10 |
/* Table of printing conversions for: d, i, u, c, %. */ |
/** |
* Table of printing conversions for: d, i, u, c, %. |
*/ |
char conversions[TOTAL_CONVERSIONS]; |
char format_string[3] = "%"; |
static int validate_string(char conv); |
/** |
* Connects to SERVICE_CONSOLE and initializes used data structures |
*/ |
int init_printing() |
{ |
40,6 → 80,9 |
} |
/** |
* Check whether the conversion character matches the conversions table |
*/ |
int validate_string(char conv) |
{ |
55,6 → 98,9 |
return FALSE; |
} |
/** |
* Prints char* on console |
*/ |
int print_console(char *str) |
{ |
77,6 → 123,9 |
return TRUE; |
} |
/** |
* Prints int argument with specified conversion inside input string |
*/ |
int print_console_int(char *str, int arg) |
{ |
147,3 → 196,8 |
return TRUE; |
} |
/** |
* } |
*/ |
/branches/fs/uspace/fs/const.h |
---|
32,67 → 32,66 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/* Constants of all file system. Some of them are not used here in |
* current version, but will be used in later versions probably. |
/** |
* @file const.h |
* @brief Constants of all file system. Some of them are not used here in |
* current version, but will be used in later versions probably. |
*/ |
#ifndef _CONST_H |
#define _CONST_H |
/* Defined in ../share/base_const.h */ |
/* |
#define FALSE 0 |
#define TRUE 1 |
#define OK 0 |
*/ |
#define BLOCK_SIZE 1024 /**< # bytes in a disk block */ |
#define MAJOR 8 /**< major device = (dev>>MAJOR) & 0377 */ |
#define MINOR 0 /**< minor device = (dev>>MINOR) & 0377 */ |
#define BYTE 0377 /**< mask for 8 bits */ |
#define NO_NUM 0x8000 /**< used as numerical argument to panic() */ |
#define BLOCK_SIZE 1024 /* # bytes in a disk block */ |
#define MAJOR 8 /* major device = (dev>>MAJOR) & 0377 */ |
#define MINOR 0 /* minor device = (dev>>MINOR) & 0377 */ |
#define BYTE 0377 /* mask for 8 bits */ |
#define NO_NUM 0x8000 /* used as numerical argument to panic() */ |
/* Not used here. */ |
#define NR_SEGS 3 /* # segments per process */ |
#define T 0 /* proc[i].mem_map[T] is for text */ |
#define D 1 /* proc[i].mem_map[D] is for data */ |
#define S 2 /* proc[i].mem_map[S] is for stack */ |
#define NR_SEGS 3 /**< # segments per process */ |
#define T 0 /**< proc[i].mem_map[T] is for text */ |
#define D 1 /**< proc[i].mem_map[D] is for data */ |
#define S 2 /**< proc[i].mem_map[S] is for stack */ |
#define MAX(a, b) ((a) > (b) ? (a) : (b)) |
#define MIN(a, b) ((a) < (b) ? (a) : (b)) |
#define I_NOT_ALLOC 0000000 /* this inode is free */ |
#define I_NOT_ALLOC 0000000 /**< this inode is free */ |
#define I_TYPE 0170000 /* this field gives inode type */ |
#define I_REGULAR 0100000 /* regular file, not dir or special */ |
#define I_DIRECTORY 0040000 /* file is a directory */ |
#define I_BLOCK_SPECIAL 0060000 /* block special file */ |
#define I_CHAR_SPECIAL 0020000 /* character special file */ |
#define I_TYPE 0170000 /**< this field gives inode type */ |
#define I_REGULAR 0100000 /**< regular file, not dir or special */ |
#define I_DIRECTORY 0040000 /**< file is a directory */ |
#define I_BLOCK_SPECIAL 0060000 /**< block special file */ |
#define I_CHAR_SPECIAL 0020000 /**< character special file */ |
#define MAX_FILE_POS ((off_t) 037777777777) /* largest legal file offset */ |
#define MAX_FILE_POS ((off_t) 037777777777) /**< largest legal file offset */ |
#define R_BIT 0000004 /* Rwx protection bit */ |
#define W_BIT 0000002 /* rWx protection bit */ |
#define X_BIT 0000001 /* rwX protection bit */ |
#define R_BIT 0000004 /**< Rwx protection bit */ |
#define W_BIT 0000002 /**< rWx protection bit */ |
#define X_BIT 0000001 /**< rwX protection bit */ |
#define NO_BLOCK ((block_num_t) 0) /* absence of a block number */ |
#define NO_ZONE ((zone_t) 0) /* absence of a zone number */ |
#define NO_DEV ((dev_t) 0) /* absence of a device numb */ |
#define NO_BLOCK ((block_num_t) 0) /**< absence of a block number */ |
#define NO_ZONE ((zone_t) 0) /**< absence of a zone number */ |
#define NO_DEV ((dev_t) 0) /**< absence of a device numb */ |
/* Tables sizes. */ |
#define V1_NR_DZONES 7 /* # direct zone numbers in a V1 inode */ |
#define V1_NR_TZONES 9 /* total # zone numbers in a V1 inode */ |
#define V2_NR_DZONES 7 /* # direct zone numbers in a V2 inode */ |
#define V2_NR_TZONES 10 /* total # zone numbers in a V2 inode */ |
#define V1_NR_DZONES 7 /**< # direct zone numbers in a V1 inode */ |
#define V1_NR_TZONES 9 /**< total # zone numbers in a V1 inode */ |
#define V2_NR_DZONES 7 /**< # direct zone numbers in a V2 inode */ |
#define V2_NR_TZONES 10 /**< total # zone numbers in a V2 inode */ |
#define NR_FILPS 128 /* # slots in filp table */ |
#define NR_INODES 64 /* # slots in "in core" inode table */ |
#define NR_FILPS 128 /**< # slots in filp table */ |
#define NR_INODES 64 /**< # slots in "in core" inode table */ |
/* The type of sizeof may be (unsigned) long. Use the following macro for |
/** |
* The type of sizeof may be (unsigned) long. Use the following macro for |
* taking the sizes of small objects so that there are no surprises like |
* (small) long constants being passed to routines expecting an int. |
*/ |
100,69 → 99,69 |
/* File system macros corresponding with given versions. */ |
#define SUPER_MAGIC 0x137F /* magic number for V1 file systems */ |
#define SUPER_MAGIC2 0x138F /* magic number for V1 file systems - 30 char names */ |
#define SUPER_V2 0x2468 /* magic number for V2 file systems */ |
#define SUPER_V2E 0x2478 /* magic number for V2 file systems - 30 char names */ |
#define SUPER_MAGIC 0x137F /**< magic number for V1 file systems */ |
#define SUPER_MAGIC2 0x138F /**< magic number for V1 file systems - 30 char names */ |
#define SUPER_V2 0x2468 /**< magic number for V2 file systems */ |
#define SUPER_V2E 0x2478 /**< magic number for V2 file systems - 30 char names */ |
#define TOTAL_VERSIONS 2 /* number of versions of file system */ |
#define TOTAL_VERSIONS 2 /**< number of versions of file system */ |
#define V1 1 /* version number of V2 file systems */ |
#define V2 2 /* version number of V2 file systems */ |
#define V1 1 /**< version number of V2 file systems */ |
#define V2 2 /**< version number of V2 file systems */ |
#define LOOK_UP 0 /* tells search_dir to lookup string */ |
#define IS_EMPTY 3 /* tells search_dir to ret. OK or ENOTEMPTY */ |
#define LOOK_UP 0 /**< tells search_dir to lookup string */ |
#define IS_EMPTY 3 /**< tells search_dir to ret. OK or ENOTEMPTY */ |
#define BYTE_SWAP 0 /* tells conv2/conv4 to swap bytes */ |
#define DONT_SWAP 1 /* tells conv2/conv4 not to swap bytes */ |
#define BYTE_SWAP 0 /**< tells conv2/conv4 to swap bytes */ |
#define DONT_SWAP 1 /**< tells conv2/conv4 not to swap bytes */ |
#define END_OF_FILE (-104) /* eof detected */ |
#define END_OF_FILE (-104) /**< eof detected */ |
#define ROOT_INODE 1 /* inode number for root directory */ |
#define BOOT_BLOCK ((block_num_t) 0) /* block number of boot block */ |
#define SUPER_BLOCK ((block_num_t) 1) /* block number of super block */ |
#define ROOT_INODE 1 /**< inode number for root directory */ |
#define BOOT_BLOCK ((block_num_t) 0) /**< block number of boot block */ |
#define SUPER_BLOCK ((block_num_t) 1) /**< block number of super block */ |
/* For normal version. */ |
#define DIR_ENTRY_SIZE usizeof (direct_t) /* # bytes/dir entry */ |
#define NR_DIR_ENTRIES (BLOCK_SIZE/DIR_ENTRY_SIZE) /* # dir entries/blk */ |
#define DIR_ENTRY_SIZE usizeof (direct_t) /**< # bytes/dir entry */ |
#define NR_DIR_ENTRIES (BLOCK_SIZE/DIR_ENTRY_SIZE) /**< # dir entries/blk */ |
/* For extended version. */ |
#define DIR_ENTRY_SIZE_EX usizeof (directex_t) /* # bytes/dir entry */ |
#define NR_DIR_ENTRIES_EX (BLOCK_SIZE/DIR_ENTRY_SIZE_EX) /* # dir entries/blk */ |
#define DIR_ENTRY_SIZE_EX usizeof (directex_t) /**< # bytes/dir entry */ |
#define NR_DIR_ENTRIES_EX (BLOCK_SIZE/DIR_ENTRY_SIZE_EX) /**< # dir entries/blk */ |
#define SUPER_SIZE usizeof (super_block_t) /* super_block size */ |
#define SUPER_SIZE usizeof (super_block_t) /**< super_block size */ |
/* Derived sizes pertaining to the V1 file system. */ |
#define V1_ZONE_NUM_SIZE usizeof (zone1_t) /* # bytes in V1 zone */ |
#define V1_INODE_SIZE usizeof (d1_inode_t) /* bytes in V1 dsk ino */ |
#define V1_INDIRECTS (BLOCK_SIZE/V1_ZONE_NUM_SIZE) /* # zones/indir block */ |
#define V1_INODES_PER_BLOCK (BLOCK_SIZE/V1_INODE_SIZE)/* # V1 dsk inodes/blk */ |
#define V1_ZONE_NUM_SIZE usizeof (zone1_t) /**< # bytes in V1 zone */ |
#define V1_INODE_SIZE usizeof (d1_inode_t) /**< bytes in V1 dsk ino */ |
#define V1_INDIRECTS (BLOCK_SIZE/V1_ZONE_NUM_SIZE) /**< # zones/indir block */ |
#define V1_INODES_PER_BLOCK (BLOCK_SIZE/V1_INODE_SIZE)/**< # V1 dsk inodes/blk */ |
/* Derived sizes pertaining to the V2 file system. */ |
#define V2_ZONE_NUM_SIZE usizeof (zone_t) /* # bytes in V2 zone */ |
#define V2_INODE_SIZE usizeof (d2_inode_t) /* bytes in V2 dsk ino */ |
#define V2_INDIRECTS (BLOCK_SIZE/V2_ZONE_NUM_SIZE) /* # zones/indir block */ |
#define V2_INODES_PER_BLOCK (BLOCK_SIZE/V2_INODE_SIZE)/* # V2 dsk inodes/blk */ |
#define V2_ZONE_NUM_SIZE usizeof (zone_t) /**< # bytes in V2 zone */ |
#define V2_INODE_SIZE usizeof (d2_inode_t) /**< bytes in V2 dsk ino */ |
#define V2_INDIRECTS (BLOCK_SIZE/V2_ZONE_NUM_SIZE) /**< # zones/indir block */ |
#define V2_INODES_PER_BLOCK (BLOCK_SIZE/V2_INODE_SIZE)/**< # V2 dsk inodes/blk */ |
/* Filesystem supported operations. */ |
#define FS_NEW_CONSUMER (FIRST_USER_METHOD + 50) /* this is not file system system call */ |
#define FS_DROP_CONSUMER (FS_NEW_CONSUMER + 1) /* drops connected consument */ |
#define FS_NEW_CONSUMER (FIRST_USER_METHOD + 50) /**< this is not file system system call */ |
#define FS_DROP_CONSUMER (FS_NEW_CONSUMER + 1) /**< drops connected consument */ |
#define FS_BASE FIRST_USER_METHOD |
#define FS_NOSYS (0 + FS_BASE) |
#define FS_OPEN (1 + FS_BASE) |
#define FS_SEEK (2 + FS_BASE) |
#define FS_READ (3 + FS_BASE) |
#define FS_CLOSE (4 + FS_BASE) |
#define FS_CHDIR (5 + FS_BASE) |
#define FS_STAT (6 + FS_BASE) |
#define FS_FSTAT (7 + FS_BASE) |
#define FS_DSUM (8 + FS_BASE) |
#define FS_READENTRY (9 + FS_BASE) |
#define FS_BASE FIRST_USER_METHOD /**> Index of the first FS method */ |
#define FS_NOSYS (0 + FS_BASE) /**> */ |
#define FS_OPEN (1 + FS_BASE) /**> Open file method */ |
#define FS_SEEK (2 + FS_BASE) /**> Seek in file method */ |
#define FS_READ (3 + FS_BASE) /**> File read method */ |
#define FS_CLOSE (4 + FS_BASE) /**> File close method */ |
#define FS_CHDIR (5 + FS_BASE) /**> Change current directory method */ |
#define FS_STAT (6 + FS_BASE) /**> Stat method */ |
#define FS_FSTAT (7 + FS_BASE) /**> File stat method */ |
#define FS_DSUM (8 + FS_BASE) /**> Directory entry count method */ |
#define FS_READENTRY (9 + FS_BASE) /**> Read directory entry method */ |
#define FS_CALLS 10 |
#define FS_CALLS 10 /**> The number of File system calls */ |
#define FS_MIN (FS_BASE) |
#define FS_MAX (FS_BASE + FS_CALLS) |
169,8 → 168,12 |
#define FS_IN_RANGE(VAL) ((FS_MIN <= VAL && VAL < FS_MAX)? TRUE:FALSE) |
/* Number of attempts the FS will try to connect to each defined services. */ |
#define CON_CONN_ATTEMPTS 1000 |
#define RD_CONN_ATTEMPTS 1000 |
#define CON_CONN_ATTEMPTS 1000 /**< Number of attempts the FS will try to connect to the console services. */ |
#define RD_CONN_ATTEMPTS 1000 /**< Number of attempts the FS will try to connect to the RAM disk services. */ |
#endif /* _CONST_H */ |
/** |
* } |
*/ |
/branches/fs/uspace/fs/path.c |
---|
1,6 → 1,3 |
/* This file contains the procedures that look up path names in the directory |
* system and determine the inode number that goes with a given path name. |
*/ |
/* |
* Copyright (c) 1987,1997, Prentice Hall |
* All rights reserved. |
35,17 → 32,18 |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
/** @addtogroup FileSystemImpl |
* @{ |
*/ |
/** |
* @file path.c |
* @brief This file contains the procedures that look up path names in the directory |
* system and determine the inode number that goes with a given path name. |
*/ |
/* Methods: |
* eat_path: the 'main' routine of the path-to-inode conversion mechanism |
* last_dir: find the final directory on a given path |
* advance: parse one component of a path name |
* search_dir: search a directory for a string and return its inode number |
* search_dir_ex: used for extended versions |
*/ |
#include <string.h> |
#include "fs.h" |
#include "block.h" |
57,6 → 55,9 |
static char *get_name(char *old_name, char *string, int string_length); |
/** |
* The 'main' routine of the path-to-inode conversion mechanism |
*/ |
inode_t *eat_path(char *path) |
{ |
92,7 → 93,10 |
return rip; |
} |
/** |
* Find the final directory on a given path |
*/ |
inode_t *last_dir(char *path, char *string, int string_length) |
{ |
151,6 → 155,9 |
} |
} |
/** |
* Parse one component of a path name |
*/ |
char *get_name(char *old_name, char *string, int string_length) |
{ |
194,7 → 201,10 |
return rnp; |
} |
/** |
* |
*/ |
inode_t *advance(inode_t *dirp, char *string, int string_length) |
{ |
238,6 → 248,9 |
return rip; /* return pointer to inode's component */ |
} |
/** |
* Search a directory for a string and return its inode number |
*/ |
int search_dir(register inode_t *ldir_ptr, char string[NAME_MAX], ino_t *numb, int flag) |
{ |
305,6 → 318,9 |
return(flag == IS_EMPTY ? OK : FS_ENOENT); |
} |
/** |
* Used for extended versions |
*/ |
int search_dir_ex(register inode_t *ldir_ptr, char string[NAME_MAX_EX], ino_t *numb, int flag) |
{ |
369,3 → 385,8 |
return(flag == IS_EMPTY ? OK : FS_ENOENT); |
} |
/** |
* } |
*/ |