Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libstand/dosfs.c
Show First 20 Lines • Show All 433 Lines • ▼ Show 20 Lines | |||||
static int | static int | ||||
dos_readdir(struct open_file *fd, struct dirent *d) | dos_readdir(struct open_file *fd, struct dirent *d) | ||||
{ | { | ||||
/* DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; */ | /* DOS_FILE *f = (DOS_FILE *)fd->f_fsdata; */ | ||||
u_char fn[261]; | u_char fn[261]; | ||||
DOS_DIR dd; | DOS_DIR dd; | ||||
size_t res; | size_t res; | ||||
u_int chk, i, x, xdn; | u_int chk, x, xdn; | ||||
int err; | int err; | ||||
x = chk = 0; | x = chk = 0; | ||||
while (1) { | while (1) { | ||||
xdn = x; | xdn = x; | ||||
x = 0; | x = 0; | ||||
err = dos_read(fd, &dd, sizeof(dd), &res); | err = dos_read(fd, &dd, sizeof(dd), &res); | ||||
if (err) | if (err) | ||||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static int | static int | ||||
lookup(DOS_FS *fs, u_int clus, const char *name, DOS_DE **dep) | lookup(DOS_FS *fs, u_int clus, const char *name, DOS_DE **dep) | ||||
{ | { | ||||
static DOS_DIR dir[DEPSEC]; | static DOS_DIR dir[DEPSEC]; | ||||
u_char lfn[261]; | u_char lfn[261]; | ||||
u_char sfn[13]; | u_char sfn[13]; | ||||
u_int nsec, lsec, xdn, chk, sec, ent, x; | u_int nsec, lsec, xdn, chk, sec, ent, x; | ||||
int err, ok, i; | int err, ok; | ||||
if (!clus) | if (!clus) | ||||
for (ent = 0; ent < 2; ent++) | for (ent = 0; ent < 2; ent++) | ||||
if (!strcasecmp(name, dotstr[ent])) { | if (!strcasecmp(name, dotstr[ent])) { | ||||
*dep = dot + ent; | *dep = dot + ent; | ||||
return 0; | return 0; | ||||
} | } | ||||
if (!clus && fs->fatsz == 32) | if (!clus && fs->fatsz == 32) | ||||
▲ Show 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
u_char buf[4]; | u_char buf[4]; | ||||
u_char *s; | u_char *s; | ||||
u_int x, offset, off, n, nbyte, lsec; | u_int x, offset, off, n, nbyte, lsec; | ||||
struct devdesc *dd = fs->fd->f_devdata; | struct devdesc *dd = fs->fd->f_devdata; | ||||
int err = 0; | int err = 0; | ||||
if (fat.unit != dd->d_unit) { | if (fat.unit != dd->d_unit) { | ||||
/* fat cache was changed to another device, dont use it */ | /* fat cache was changed to another device, don't use it */ | ||||
err = ioread(fs, secbyt(fs->lsnfat) + fatoff(fs->fatsz, *c), buf, | err = ioread(fs, secbyt(fs->lsnfat) + fatoff(fs->fatsz, *c), buf, | ||||
fs->fatsz != 32 ? 2 : 4); | fs->fatsz != 32 ? 2 : 4); | ||||
if (err) | if (err) | ||||
return err; | return (err); | ||||
} else { | } else { | ||||
offset = fatoff(fs->fatsz, *c); | offset = fatoff(fs->fatsz, *c); | ||||
nbyte = fs->fatsz != 32 ? 2 : 4; | nbyte = fs->fatsz != 32 ? 2 : 4; | ||||
s = buf; | s = buf; | ||||
if ((off = offset & (SECSIZ - 1))) { | if ((off = offset & (SECSIZ - 1))) { | ||||
offset -= off; | offset -= off; | ||||
lsec = bytsec(offset); | lsec = bytsec(offset); | ||||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |