xv6/fs.c File Reference

#include "types.h"
#include "defs.h"
#include "param.h"
#include "stat.h"
#include "mmu.h"
#include "proc.h"
#include "spinlock.h"
#include "buf.h"
#include "fs.h"
#include "file.h"

Go to the source code of this file.

Defines

#define min(a, b)   ((a) < (b) ? (a) : (b))

Functions

static void itrunc (struct inode *)
static void readsb (int dev, struct superblock *sb)
static void bzero (int dev, int bno)
static uint balloc (uint dev)
static void bfree (int dev, uint b)
void iinit (void)
static struct inodeiget (uint dev, uint inum)
struct inodeialloc (uint dev, short type)
void iupdate (struct inode *ip)
struct inodeidup (struct inode *ip)
void ilock (struct inode *ip)
void iunlock (struct inode *ip)
void iput (struct inode *ip)
void iunlockput (struct inode *ip)
static uint bmap (struct inode *ip, uint bn)
void stati (struct inode *ip, struct stat *st)
int readi (struct inode *ip, char *dst, uint off, uint n)
int writei (struct inode *ip, char *src, uint off, uint n)
int namecmp (const char *s, const char *t)
struct inodedirlookup (struct inode *dp, char *name, uint *poff)
int dirlink (struct inode *dp, char *name, uint inum)
static char * skipelem (char *path, char *name)
static struct inodenamex (char *path, int nameiparent, char *name)
struct inodenamei (char *path)
struct inodenameiparent (char *path, char *name)

Variables

struct {
   struct spinlock   lock
   struct inode   inode [NINODE]
icache


Define Documentation

#define min ( a,
 )     ((a) < (b) ? (a) : (b))

Definition at line 24 of file fs.c.

Referenced by iappend(), readi(), and writei().


Function Documentation

static uint balloc ( uint  dev  )  [static]

Definition at line 54 of file fs.c.

References BBLOCK, BPB, bread(), brelse(), bwrite(), superblock::ninodes, panic(), readsb(), and superblock::size.

Referenced by bmap(), and main().

static void bfree ( int  dev,
uint  b 
) [static]

Definition at line 80 of file fs.c.

References BBLOCK, BPB, bread(), brelse(), bwrite(), bzero(), buf::data, superblock::ninodes, panic(), and readsb().

Referenced by itrunc().

static uint bmap ( struct inode ip,
uint  bn 
) [static]

Definition at line 320 of file fs.c.

References inode::addrs, balloc(), bread(), brelse(), bwrite(), buf::data, inode::dev, NDIRECT, NINDIRECT, and panic().

Referenced by dirlookup(), readi(), and writei().

static void bzero ( int  dev,
int  bno 
) [static]

Definition at line 40 of file fs.c.

References bread(), brelse(), BSIZE, bwrite(), buf::data, and memset().

Referenced by balloc(), bfree(), ialloc(), and main().

int dirlink ( struct inode dp,
char *  name,
uint  inum 
)

Definition at line 497 of file fs.c.

References dirlookup(), DIRSIZ, dirent::inum, iput(), dirent::name, panic(), readi(), inode::size, strncpy(), and writei().

Referenced by create(), and sys_link().

struct inode* dirlookup ( struct inode dp,
char *  name,
uint poff 
) [read]

struct inode* ialloc ( uint  dev,
short  type 
) [read]

Definition at line 147 of file fs.c.

References bread(), brelse(), bwrite(), buf::data, IBLOCK, iget(), inode::inum, IPB, memset(), superblock::ninodes, panic(), readsb(), and dinode::type.

Referenced by create(), and main().

struct inode* idup ( struct inode ip  )  [read]

Definition at line 227 of file fs.c.

References acquire(), icache, inode::ref, and release().

Referenced by fork(), and namex().

static struct inode * iget ( uint  dev,
uint  inum 
) [static, read]

Definition at line 192 of file fs.c.

References acquire(), inode::dev, inode::flags, icache, inode::inum, NINODE, panic(), inode::ref, and release().

Referenced by dirlookup(), ialloc(), and namex().

void iinit ( void   ) 

Definition at line 138 of file fs.c.

References icache, and initlock().

Referenced by mpmain().

void ilock ( struct inode ip  ) 

void iput ( struct inode ip  ) 

static void itrunc ( struct inode ip  )  [static]

Definition at line 353 of file fs.c.

References inode::addrs, bfree(), bread(), brelse(), buf::data, inode::dev, iupdate(), NDIRECT, NINDIRECT, and inode::size.

Referenced by iput().

void iunlock ( struct inode ip  ) 

void iunlockput ( struct inode ip  ) 

Definition at line 304 of file fs.c.

References iput(), and iunlock().

Referenced by create(), exec(), namex(), sys_chdir(), sys_link(), sys_mkdir(), sys_mknod(), sys_open(), and sys_unlink().

void iupdate ( struct inode ip  ) 

int namecmp ( const char *  s,
const char *  t 
)

Definition at line 456 of file fs.c.

References DIRSIZ, and strncmp().

Referenced by dirlookup(), and sys_unlink().

struct inode* namei ( char *  path  )  [read]

Definition at line 603 of file fs.c.

References DIRSIZ, name, and namex().

Referenced by exec(), sys_chdir(), sys_link(), sys_open(), and userinit().

struct inode* nameiparent ( char *  path,
char *  name 
) [read]

Definition at line 610 of file fs.c.

References namex().

Referenced by create(), sys_link(), and sys_unlink().

static struct inode* namex ( char *  path,
int  nameiparent,
char *  name 
) [static, read]

Definition at line 568 of file fs.c.

References dirlookup(), idup(), iget(), ilock(), iput(), iunlock(), iunlockput(), ROOTDEV, ROOTINO, skipelem(), T_DIR, and inode::type.

Referenced by namei(), and nameiparent().

int readi ( struct inode ip,
char *  dst,
uint  off,
uint  n 
)

Definition at line 395 of file fs.c.

References bmap(), bread(), brelse(), BSIZE, buf::data, inode::dev, inode::major, memmove(), min, NDEV, inode::size, T_DEV, and inode::type.

Referenced by dirlink(), exec(), fileread(), and isdirempty().

static void readsb ( int  dev,
struct superblock sb 
) [static]

Definition at line 29 of file fs.c.

References bread(), brelse(), buf::data, and memmove().

Referenced by balloc(), bfree(), and ialloc().

static char* skipelem ( char *  path,
char *  name 
) [static]

Definition at line 540 of file fs.c.

References DIRSIZ, and memmove().

Referenced by namex().

void stati ( struct inode ip,
struct stat st 
)

Definition at line 384 of file fs.c.

References inode::dev, stat::dev, stat::ino, inode::inum, inode::nlink, stat::nlink, inode::size, stat::size, inode::type, and stat::type.

Referenced by filestat().

int writei ( struct inode ip,
char *  src,
uint  off,
uint  n 
)


Variable Documentation

struct { ... } icache

Referenced by idup(), iget(), iinit(), ilock(), iput(), and iunlock().

struct inode inode[NINODE]

Definition at line 134 of file fs.c.

struct spinlock lock

Definition at line 133 of file fs.c.


Generated on Fri Jan 7 12:25:49 2011 for xv6 by  doxygen 1.5.6