file.c File Reference

#include "sysincludes.h"
#include "msdos.h"
#include "stream.h"
#include "mtools.h"
#include "fsP.h"
#include "file.h"
#include "htable.h"
#include "dirCache.h"

Include dependency graph for file.c:

Go to the source code of this file.

Data Structures

struct  File_t

Functions

static File_tgetUnbufferedFile (Stream_t *Stream)
Fs_tgetFs (Stream_t *Stream)
dirCache_t ** getDirCacheP (Stream_t *Stream)
direntry_tgetDirentry (Stream_t *Stream)
static int recalcPreallocSize (File_t *This)
static int _loopDetect (unsigned int *oldrel, unsigned int rel, unsigned int *oldabs, unsigned int abs)
static int loopDetect (File_t *This, unsigned int rel, unsigned int abs)
static unsigned int _countBlocks (Fs_t *This, unsigned int block)
unsigned int countBlocks (Stream_t *Dir, unsigned int block)
static size_t countBytes (Stream_t *Dir, unsigned int block)
void printFat (Stream_t *Stream)
static int normal_map (File_t *This, off_t where, size_t *len, int mode, mt_off_t *res)
static int root_map (File_t *This, off_t where, size_t *len, int mode, mt_off_t *res)
static int read_file (Stream_t *Stream, char *buf, mt_off_t iwhere, size_t len)
static int write_file (Stream_t *Stream, char *buf, mt_off_t iwhere, size_t len)
static time_t conv_stamp (struct directory *dir)
static int get_file_data (Stream_t *Stream, time_t *date, mt_size_t *size, int *type, int *address)
static int free_file (Stream_t *Stream)
static int flush_file (Stream_t *Stream)
static int pre_allocate_file (Stream_t *Stream, mt_size_t isize)
static unsigned int getAbsCluNr (File_t *This)
static unsigned int func1 (void *Stream)
static unsigned int func2 (void *Stream)
static int comp (void *Stream, void *Stream2)
static void init_hash (void)
static Stream_t_internalFileOpen (Stream_t *Dir, unsigned int first, size_t size, direntry_t *entry)
Stream_tOpenRoot (Stream_t *Dir)
Stream_tOpenFileByDirentry (direntry_t *entry)
int isRootDir (Stream_t *Stream)

Variables

static Class_t FileClass
T_HashTablefilehash
static int month []
static Class_t FileClass


Function Documentation

static unsigned int _countBlocks Fs_t This,
unsigned int  block
[static]
 

Definition at line 117 of file file.c.

References _loopDetect(), blocks, and fatDecode().

Referenced by countBlocks(), and countBytes().

static Stream_t* _internalFileOpen Stream_t Dir,
unsigned int  first,
size_t  size,
direntry_t entry
[static]
 

Definition at line 552 of file file.c.

References File_t::Class, COPY, DeclareThis, entry, FileClass, filehash, File_t::FirstAbsCluNr, File_t::Fs, GetFs(), hash_add(), hash_lookup(), init_hash(), IS_DIR, File_t::loopDetectAbs, File_t::loopDetectRel, File_t::map, New, normal_map(), NULL, and root_map().

Referenced by OpenFileByDirentry(), and OpenRoot().

static int _loopDetect unsigned int *  oldrel,
unsigned int  rel,
unsigned int *  oldabs,
unsigned int  abs
[static]
 

Definition at line 95 of file file.c.

References fprintf(), and stderr.

Referenced by _countBlocks(), and loopDetect().

static int comp void *  Stream,
void *  Stream2
[static]
 

Definition at line 531 of file file.c.

References DeclareThis, File_t::Fs, and getAbsCluNr().

Referenced by init_hash(), and re_compile().

static time_t conv_stamp struct directory dir  )  [inline, static]
 

Definition at line 377 of file file.c.

References dir, DOS_DAY, DOS_HOUR, DOS_MINUTE, DOS_MONTH, DOS_SEC, DOS_YEAR, gettimeofday(), L, localtime(), long(), month, time_t, timezone, tm::tm_isdst, tmp, and tzset().

Referenced by get_file_data().

unsigned int countBlocks Stream_t Dir,
unsigned int  block
 

Definition at line 136 of file file.c.

References _countBlocks(), DeclareThis, and GetFs().

Referenced by dir_mdu(), and file_mdu().

static size_t countBytes Stream_t Dir,
unsigned int  block
[static]
 

Definition at line 147 of file file.c.

References _countBlocks(), DeclareThis, and GetFs().

Referenced by OpenFileByDirentry(), and OpenRoot().

static int flush_file Stream_t Stream  )  [static]
 

Definition at line 466 of file file.c.

References DeclareThis, entry::dir, dir_write(), entry, getStart(), and isRootDir().

static int free_file Stream_t Stream  )  [static]
 

Definition at line 455 of file file.c.

References DeclareThis, filehash, FREE, freeDirCache(), fsPreallocateClusters(), hash_remove(), and Fs_t::preallocatedClusters.

static unsigned int func1 void *  Stream  )  [static]
 

Definition at line 517 of file file.c.

References DeclareThis, getAbsCluNr(), and long().

Referenced by init_hash().

static unsigned int func2 void *  Stream  )  [static]
 

Definition at line 524 of file file.c.

References DeclareThis, and getAbsCluNr().

Referenced by init_hash().

static int get_file_data Stream_t Stream,
time_t date,
mt_size_t size,
int *  type,
int *  address
[static]
 

Definition at line 438 of file file.c.

References ATTR_DIR, conv_stamp(), and DeclareThis.

static unsigned int getAbsCluNr File_t This  )  [static]
 

Definition at line 508 of file file.c.

References File_t::FirstAbsCluNr, and isRootDir().

Referenced by comp(), func1(), and func2().

struct dirCache_t** getDirCacheP Stream_t Stream  ) 
 

Definition at line 54 of file file.c.

References File_t::dcp, and getUnbufferedFile().

Referenced by allocDirCache(), and freeDirCache().

direntry_t* getDirentry Stream_t Stream  ) 
 

Definition at line 59 of file file.c.

References File_t::direntry, and getUnbufferedFile().

Referenced by _fprintPwd(), dos_copydir(), enterDirectory(), getParent(), getPathLen(), isSubdirOf(), recurs_dos_loop(), rename_directory(), renameit(), and sprintPwd().

Fs_t* getFs Stream_t Stream  ) 
 

Definition at line 49 of file file.c.

References File_t::Fs, and getUnbufferedFile().

Referenced by dos_doctorfat().

static File_t* getUnbufferedFile Stream_t Stream  )  [static]
 

Definition at line 42 of file file.c.

References Stream_t::Class, FileClass, and Stream_t::Next.

Referenced by getDirCacheP(), getDirentry(), getFs(), isRootDir(), and printFat().

static void init_hash void   )  [static]
 

Definition at line 541 of file file.c.

References comp(), filehash, func1(), func2(), and make_ht().

Referenced by _internalFileOpen().

int isRootDir Stream_t Stream  ) 
 

Definition at line 671 of file file.c.

References getUnbufferedFile(), File_t::map, and root_map().

Referenced by dir_mdu(), flush_file(), getAbsCluNr(), and lookupForInsert().

static int loopDetect File_t This,
unsigned int  rel,
unsigned int  abs
[static]
 

Definition at line 112 of file file.c.

References _loopDetect(), File_t::loopDetectAbs, and File_t::loopDetectRel.

Referenced by normal_map(), and printFat().

static int normal_map File_t This,
off_t  where,
size_t len,
int  mode,
mt_off_t res
[static]
 

Definition at line 198 of file file.c.

References batchmode, Fs_t::cluster_size, EIO, Fs_t::end_fat, ENOSPC, errno, exit(), fatAllocate(), fatAppend(), fatDecode(), filehash, File_t::FileSize, File_t::FirstAbsCluNr, fprintf(), File_t::Fs, get_next_free_cluster(), hash_add(), hash_remove(), File_t::hint, Fs_t::last_fat, loopDetect(), maximize, MT_READ, MT_WRITE, Fs_t::num_clus, offset, File_t::PreviousAbsCluNr, File_t::PreviousRelCluNr, ROUND_UP, Fs_t::sector_size, sectorsToBytes(), and stderr.

Referenced by _internalFileOpen().

Stream_t* OpenFileByDirentry direntry_t entry  ) 
 

Definition at line 646 of file file.c.

References _internalFileOpen(), bufferize(), countBytes(), entry::dir, dir_grow(), entry, file, FILE_SIZE, first, getStart(), IS_DIR, OpenRoot(), and size.

Referenced by _dos_loop(), del_file(), handle_leaf(), makeit(), recurs_dos_loop(), and subDir().

Stream_t* OpenRoot Stream_t Dir  ) 
 

Definition at line 618 of file file.c.

References _internalFileOpen(), ATTR_DIR, bufferize(), countBytes(), entry::dir, Fs_t::dir_len, entry, fat32RootCluster(), file, GetFs(), memset(), mk_entry(), entry::name, num(), Fs_t::sector_size, and size.

Referenced by format_root(), OpenFileByDirentry(), and print_volume_label().

static int pre_allocate_file Stream_t Stream,
mt_size_t  isize
[static]
 

Definition at line 484 of file file.c.

References DeclareThis, recalcPreallocSize(), size, and truncBytes32().

void printFat Stream_t Stream  ) 
 

Definition at line 156 of file file.c.

References begin, fatDecode(), first, File_t::FirstAbsCluNr, File_t::Fs, getUnbufferedFile(), loopDetect(), n, and printf.

Referenced by dos_showfat().

static int read_file Stream_t Stream,
char *  buf,
mt_off_t  iwhere,
size_t  len
[static]
 

Definition at line 328 of file file.c.

References DeclareThis, err, MT_READ, pos, READS, truncBytes32(), and where.

static int recalcPreallocSize File_t This  )  [static]
 

Definition at line 65 of file file.c.

References Fs_t::cluster_size, File_t::FileSize, fprintf(), File_t::Fs, fsPreallocateClusters(), File_t::preallocatedClusters, File_t::preallocatedSize, r, Fs_t::sector_size, and stderr.

Referenced by pre_allocate_file(), and write_file().

static int root_map File_t This,
off_t  where,
size_t len,
int  mode,
mt_off_t res
[static]
 

Definition at line 308 of file file.c.

References Fs_t::dir_len, ENOSPC, errno, File_t::Fs, maximize, Fs_t::sector_size, and sectorsToBytes().

Referenced by _internalFileOpen(), and isRootDir().

static int write_file Stream_t Stream,
char *  buf,
mt_off_t  iwhere,
size_t  len
[static]
 

Definition at line 344 of file file.c.

References batchmode, DeclareThis, err, force_write(), MT_WRITE, pos, recalcPreallocSize(), truncBytes32(), where, and WRITES.


Variable Documentation

Class_t FileClass [static]
 

Initial value:

Definition at line 498 of file file.c.

Class_t FileClass [static]
 

Definition at line 39 of file file.c.

Referenced by _internalFileOpen(), and getUnbufferedFile().

T_HashTable* filehash
 

Definition at line 40 of file file.c.

Referenced by _internalFileOpen(), free_file(), init_hash(), and normal_map().

int month[] [static]
 

Initial value:

 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
                                          0, 0, 0 }

Definition at line 375 of file file.c.

Referenced by conv_stamp(), date_of(), date_pat(), doyear(), fill_date(), fmtdate(), main(), mktime(), output(), print_date(), servxcheck(), timestamp(), and write_log().


Generated on Fri Apr 14 23:03:16 2006 for minix by  doxygen 1.4.6