9bootfat: rename open() to fileinit and make it static as its really a internal function function
This commit is contained in:
parent
79af8162e8
commit
6063ab829f
1 changed files with 14 additions and 16 deletions
|
@ -163,19 +163,6 @@ read(void *f, void *data, int len)
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
open(Fat *fat, void *f, ulong lba)
|
|
||||||
{
|
|
||||||
File *fp = f;
|
|
||||||
|
|
||||||
fp->fat = fat;
|
|
||||||
fp->lba = lba;
|
|
||||||
fp->len = 0;
|
|
||||||
fp->lbaoff = 0;
|
|
||||||
fp->clust = ~0U;
|
|
||||||
fp->rp = fp->ep = fp->buf + Sectsz;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
close(void *)
|
close(void *)
|
||||||
{
|
{
|
||||||
|
@ -217,6 +204,17 @@ dirclust(Dir *d)
|
||||||
return *((ushort*)d->starthi)<<16 | *((ushort*)d->startlo);
|
return *((ushort*)d->starthi)<<16 | *((ushort*)d->startlo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
fileinit(File *fp, Fat *fat, ulong lba)
|
||||||
|
{
|
||||||
|
fp->fat = fat;
|
||||||
|
fp->lba = lba;
|
||||||
|
fp->len = 0;
|
||||||
|
fp->lbaoff = 0;
|
||||||
|
fp->clust = ~0U;
|
||||||
|
fp->rp = fp->ep = fp->buf + Sectsz;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
fatwalk(File *fp, Fat *fat, char *path)
|
fatwalk(File *fp, Fat *fat, char *path)
|
||||||
{
|
{
|
||||||
|
@ -225,11 +223,11 @@ fatwalk(File *fp, Fat *fat, char *path)
|
||||||
Dir d;
|
Dir d;
|
||||||
|
|
||||||
if(fat->ver == Fat32){
|
if(fat->ver == Fat32){
|
||||||
open(fat, fp, 0);
|
fileinit(fp, fat, 0);
|
||||||
fp->clust = fat->dirstart;
|
fp->clust = fat->dirstart;
|
||||||
fp->len = ~0U;
|
fp->len = ~0U;
|
||||||
}else{
|
}else{
|
||||||
open(fat, fp, fat->dirstart);
|
fileinit(fp, fat, fat->dirstart);
|
||||||
fp->len = fat->dirents * Dirsz;
|
fp->len = fat->dirents * Dirsz;
|
||||||
}
|
}
|
||||||
for(;;){
|
for(;;){
|
||||||
|
@ -243,7 +241,7 @@ fatwalk(File *fp, Fat *fat, char *path)
|
||||||
end = path + strlen(path);
|
end = path + strlen(path);
|
||||||
j = end - path;
|
j = end - path;
|
||||||
if(i == j && memcmp(name, path, j) == 0){
|
if(i == j && memcmp(name, path, j) == 0){
|
||||||
open(fat, fp, 0);
|
fileinit(fp, fat, 0);
|
||||||
fp->clust = dirclust(&d);
|
fp->clust = dirclust(&d);
|
||||||
fp->len = *((ulong*)d.len);
|
fp->len = *((ulong*)d.len);
|
||||||
if(*end == 0)
|
if(*end == 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue