Re-running Nindent.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
This commit is contained in:
parent
0390c4c1c1
commit
91a1fb9536
@ -89,15 +89,15 @@ static void dump_boot(DOS_FS * fs, struct boot_sector *b, unsigned lss)
|
|||||||
printf("Boot sector contents:\n");
|
printf("Boot sector contents:\n");
|
||||||
if (!atari_format) {
|
if (!atari_format) {
|
||||||
char id[9];
|
char id[9];
|
||||||
strncpy(id, (const char*)b->system_id, 8);
|
strncpy(id, (const char *)b->system_id, 8);
|
||||||
id[8] = 0;
|
id[8] = 0;
|
||||||
printf("System ID \"%s\"\n", id);
|
printf("System ID \"%s\"\n", id);
|
||||||
} else {
|
} else {
|
||||||
/* On Atari, a 24 bit serial number is stored at offset 8 of the boot
|
/* On Atari, a 24 bit serial number is stored at offset 8 of the boot
|
||||||
* sector */
|
* sector */
|
||||||
printf("Serial number 0x%x\n",
|
printf("Serial number 0x%x\n",
|
||||||
b->system_id[5] | (b->system_id[6] << 8) | (b->
|
b->system_id[5] | (b->
|
||||||
system_id[7] << 16));
|
system_id[6] << 8) | (b->system_id[7] << 16));
|
||||||
}
|
}
|
||||||
printf("Media byte 0x%02x (%s)\n", b->media, get_media_descr(b->media));
|
printf("Media byte 0x%02x (%s)\n", b->media, get_media_descr(b->media));
|
||||||
printf("%10d bytes per logical sector\n", GET_UNALIGNED_W(b->sector_size));
|
printf("%10d bytes per logical sector\n", GET_UNALIGNED_W(b->sector_size));
|
||||||
|
|||||||
65
src/check.c
65
src/check.c
@ -139,7 +139,8 @@ loff_t alloc_rootdir_entry(DOS_FS * fs, DIR_ENT * de, const char *pattern)
|
|||||||
while (clu_num > 0 && clu_num != -1) {
|
while (clu_num > 0 && clu_num != -1) {
|
||||||
fs_read(offset2, sizeof(DIR_ENT), &d2);
|
fs_read(offset2, sizeof(DIR_ENT), &d2);
|
||||||
if (offset2 != offset &&
|
if (offset2 != offset &&
|
||||||
!strncmp((const char*)d2.name, (const char*)de->name, MSDOS_NAME))
|
!strncmp((const char *)d2.name, (const char *)de->name,
|
||||||
|
MSDOS_NAME))
|
||||||
break;
|
break;
|
||||||
i += sizeof(DIR_ENT);
|
i += sizeof(DIR_ENT);
|
||||||
offset2 += sizeof(DIR_ENT);
|
offset2 += sizeof(DIR_ENT);
|
||||||
@ -173,10 +174,11 @@ loff_t alloc_rootdir_entry(DOS_FS * fs, DIR_ENT * de, const char *pattern)
|
|||||||
offset = fs->root_start + next_free * sizeof(DIR_ENT);
|
offset = fs->root_start + next_free * sizeof(DIR_ENT);
|
||||||
memset(de, 0, sizeof(DIR_ENT));
|
memset(de, 0, sizeof(DIR_ENT));
|
||||||
while (1) {
|
while (1) {
|
||||||
sprintf((char*)de->name, pattern, curr_num);
|
sprintf((char *)de->name, pattern, curr_num);
|
||||||
for (scan = 0; scan < fs->root_entries; scan++)
|
for (scan = 0; scan < fs->root_entries; scan++)
|
||||||
if (scan != next_free &&
|
if (scan != next_free &&
|
||||||
!strncmp((const char*)root[scan].name, (const char*)de->name, MSDOS_NAME))
|
!strncmp((const char *)root[scan].name,
|
||||||
|
(const char *)de->name, MSDOS_NAME))
|
||||||
break;
|
break;
|
||||||
if (scan == fs->root_entries)
|
if (scan == fs->root_entries)
|
||||||
break;
|
break;
|
||||||
@ -262,8 +264,8 @@ static int bad_name(DOS_FILE * file)
|
|||||||
|
|
||||||
/* Do not complain about (and auto-correct) the extended attribute files
|
/* Do not complain about (and auto-correct) the extended attribute files
|
||||||
* of OS/2. */
|
* of OS/2. */
|
||||||
if (strncmp((const char*)name, "EA DATA SF", 11) == 0 ||
|
if (strncmp((const char *)name, "EA DATA SF", 11) == 0 ||
|
||||||
strncmp((const char*)name, "WP ROOT SF", 11) == 0)
|
strncmp((const char *)name, "WP ROOT SF", 11) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* don't complain about the dummy 11 bytes used by patched Linux
|
/* don't complain about the dummy 11 bytes used by patched Linux
|
||||||
@ -386,13 +388,14 @@ static void auto_rename(DOS_FILE * file)
|
|||||||
memcpy(file->dir_ent.ext, num + 4, 3);
|
memcpy(file->dir_ent.ext, num + 4, 3);
|
||||||
for (walk = first; walk; walk = walk->next)
|
for (walk = first; walk; walk = walk->next)
|
||||||
if (walk != file
|
if (walk != file
|
||||||
&& !strncmp((const char*)walk->dir_ent.name, (const char*)file->dir_ent.name, MSDOS_NAME))
|
&& !strncmp((const char *)walk->dir_ent.name,
|
||||||
|
(const char *)file->dir_ent.name, MSDOS_NAME))
|
||||||
break;
|
break;
|
||||||
if (!walk) {
|
if (!walk) {
|
||||||
fs_write(file->offset, MSDOS_NAME, file->dir_ent.name);
|
fs_write(file->offset, MSDOS_NAME, file->dir_ent.name);
|
||||||
if (file->lfn)
|
if (file->lfn)
|
||||||
lfn_fix_checksum(file->lfn_offset, file->offset,
|
lfn_fix_checksum(file->lfn_offset, file->offset,
|
||||||
(const char*)file->dir_ent.name);
|
(const char *)file->dir_ent.name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
number++;
|
number++;
|
||||||
@ -415,19 +418,18 @@ static void rename_file(DOS_FILE * file)
|
|||||||
while (1) {
|
while (1) {
|
||||||
printf("New name: ");
|
printf("New name: ");
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
if (fgets((char*)name, 45, stdin)) {
|
if (fgets((char *)name, 45, stdin)) {
|
||||||
if ((here = (unsigned char*)strchr((const char*)name, '\n')))
|
if ((here = (unsigned char *)strchr((const char *)name, '\n')))
|
||||||
*here = 0;
|
*here = 0;
|
||||||
for (walk = (unsigned char*)strrchr((const char*)name, 0); walk >= name && (*walk == ' ' ||
|
for (walk = (unsigned char *)strrchr((const char *)name, 0);
|
||||||
*walk == '\t');
|
walk >= name && (*walk == ' ' || *walk == '\t'); walk--) ;
|
||||||
walk--) ;
|
|
||||||
walk[1] = 0;
|
walk[1] = 0;
|
||||||
for (walk = name; *walk == ' ' || *walk == '\t'; walk++) ;
|
for (walk = name; *walk == ' ' || *walk == '\t'; walk++) ;
|
||||||
if (file_cvt(walk, file->dir_ent.name)) {
|
if (file_cvt(walk, file->dir_ent.name)) {
|
||||||
fs_write(file->offset, MSDOS_NAME, file->dir_ent.name);
|
fs_write(file->offset, MSDOS_NAME, file->dir_ent.name);
|
||||||
if (file->lfn)
|
if (file->lfn)
|
||||||
lfn_fix_checksum(file->lfn_offset, file->offset,
|
lfn_fix_checksum(file->lfn_offset, file->offset,
|
||||||
(const char*)file->dir_ent.name);
|
(const char *)file->dir_ent.name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -438,7 +440,9 @@ static int handle_dot(DOS_FS * fs, DOS_FILE * file, int dots)
|
|||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
|
|
||||||
name = strncmp((const char*)file->dir_ent.name, MSDOS_DOT, MSDOS_NAME) ? ".." : ".";
|
name =
|
||||||
|
strncmp((const char *)file->dir_ent.name, MSDOS_DOT,
|
||||||
|
MSDOS_NAME) ? ".." : ".";
|
||||||
if (!(file->dir_ent.attr & ATTR_DIR)) {
|
if (!(file->dir_ent.attr & ATTR_DIR)) {
|
||||||
printf("%s\n Is a non-directory.\n", path_name(file));
|
printf("%s\n Is a non-directory.\n", path_name(file));
|
||||||
if (interactive)
|
if (interactive)
|
||||||
@ -483,7 +487,9 @@ static int check_file(DOS_FS * fs, DOS_FILE * file)
|
|||||||
path_name(file));
|
path_name(file));
|
||||||
MODIFY(file, size, CT_LE_L(0));
|
MODIFY(file, size, CT_LE_L(0));
|
||||||
}
|
}
|
||||||
if (file->parent && !strncmp((const char*)file->dir_ent.name, MSDOS_DOT, MSDOS_NAME)) {
|
if (file->parent
|
||||||
|
&& !strncmp((const char *)file->dir_ent.name, MSDOS_DOT,
|
||||||
|
MSDOS_NAME)) {
|
||||||
expect = FSTART(file->parent, fs);
|
expect = FSTART(file->parent, fs);
|
||||||
if (FSTART(file, fs) != expect) {
|
if (FSTART(file, fs) != expect) {
|
||||||
printf("%s\n Start (%ld) does not point to parent (%ld)\n",
|
printf("%s\n Start (%ld) does not point to parent (%ld)\n",
|
||||||
@ -492,8 +498,9 @@ static int check_file(DOS_FS * fs, DOS_FILE * file)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (file->parent && !strncmp((const char*)file->dir_ent.name, MSDOS_DOTDOT,
|
if (file->parent
|
||||||
MSDOS_NAME)) {
|
&& !strncmp((const char *)file->dir_ent.name, MSDOS_DOTDOT,
|
||||||
|
MSDOS_NAME)) {
|
||||||
expect =
|
expect =
|
||||||
file->parent->parent ? FSTART(file->parent->parent, fs) : 0;
|
file->parent->parent ? FSTART(file->parent->parent, fs) : 0;
|
||||||
if (fs->root_cluster && expect == fs->root_cluster)
|
if (fs->root_cluster && expect == fs->root_cluster)
|
||||||
@ -677,13 +684,16 @@ static int check_dir(DOS_FS * fs, DOS_FILE ** root, int dots)
|
|||||||
dot = dotdot = redo = 0;
|
dot = dotdot = redo = 0;
|
||||||
walk = root;
|
walk = root;
|
||||||
while (*walk) {
|
while (*walk) {
|
||||||
if (!strncmp((const char*)((*walk)->dir_ent.name), MSDOS_DOT, MSDOS_NAME) ||
|
if (!strncmp
|
||||||
!strncmp((const char*)((*walk)->dir_ent.name), MSDOS_DOTDOT, MSDOS_NAME)) {
|
((const char *)((*walk)->dir_ent.name), MSDOS_DOT, MSDOS_NAME)
|
||||||
|
|| !strncmp((const char *)((*walk)->dir_ent.name), MSDOS_DOTDOT,
|
||||||
|
MSDOS_NAME)) {
|
||||||
if (handle_dot(fs, *walk, dots)) {
|
if (handle_dot(fs, *walk, dots)) {
|
||||||
*walk = (*walk)->next;
|
*walk = (*walk)->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strncmp((const char*)((*walk)->dir_ent.name), MSDOS_DOT, MSDOS_NAME))
|
if (!strncmp
|
||||||
|
((const char *)((*walk)->dir_ent.name), MSDOS_DOT, MSDOS_NAME))
|
||||||
dot++;
|
dot++;
|
||||||
else
|
else
|
||||||
dotdot++;
|
dotdot++;
|
||||||
@ -920,10 +930,10 @@ static void add_file(DOS_FS * fs, DOS_FILE *** chain, DOS_FILE * parent,
|
|||||||
de.start = CT_LE_W(fs->root_cluster & 0xffff);
|
de.start = CT_LE_W(fs->root_cluster & 0xffff);
|
||||||
de.starthi = CT_LE_W((fs->root_cluster >> 16) & 0xffff);
|
de.starthi = CT_LE_W((fs->root_cluster >> 16) & 0xffff);
|
||||||
}
|
}
|
||||||
if ((type = file_type(cp, (char*)de.name)) != fdt_none) {
|
if ((type = file_type(cp, (char *)de.name)) != fdt_none) {
|
||||||
if (type == fdt_undelete && (de.attr & ATTR_DIR))
|
if (type == fdt_undelete && (de.attr & ATTR_DIR))
|
||||||
die("Can't undelete directories.");
|
die("Can't undelete directories.");
|
||||||
file_modify(cp, (char*)de.name);
|
file_modify(cp, (char *)de.name);
|
||||||
fs_write(offset, 1, &de);
|
fs_write(offset, 1, &de);
|
||||||
}
|
}
|
||||||
if (IS_FREE(de.name)) {
|
if (IS_FREE(de.name)) {
|
||||||
@ -952,8 +962,8 @@ static void add_file(DOS_FS * fs, DOS_FILE *** chain, DOS_FILE * parent,
|
|||||||
}
|
}
|
||||||
/* Don't include root directory, '.', or '..' in the total file count */
|
/* Don't include root directory, '.', or '..' in the total file count */
|
||||||
if (offset &&
|
if (offset &&
|
||||||
strncmp((const char*)de.name, MSDOS_DOT, MSDOS_NAME) != 0 &&
|
strncmp((const char *)de.name, MSDOS_DOT, MSDOS_NAME) != 0 &&
|
||||||
strncmp((const char*)de.name, MSDOS_DOTDOT, MSDOS_NAME) != 0)
|
strncmp((const char *)de.name, MSDOS_DOTDOT, MSDOS_NAME) != 0)
|
||||||
++n_files;
|
++n_files;
|
||||||
test_file(fs, new, test); /* Bad cluster check */
|
test_file(fs, new, test); /* Bad cluster check */
|
||||||
}
|
}
|
||||||
@ -1002,9 +1012,10 @@ static int subdirs(DOS_FS * fs, DOS_FILE * parent, FDSC ** cp)
|
|||||||
|
|
||||||
for (walk = parent ? parent->first : root; walk; walk = walk->next)
|
for (walk = parent ? parent->first : root; walk; walk = walk->next)
|
||||||
if (walk->dir_ent.attr & ATTR_DIR)
|
if (walk->dir_ent.attr & ATTR_DIR)
|
||||||
if (strncmp((const char*)walk->dir_ent.name, MSDOS_DOT, MSDOS_NAME) &&
|
if (strncmp((const char *)walk->dir_ent.name, MSDOS_DOT, MSDOS_NAME)
|
||||||
strncmp((const char*)walk->dir_ent.name, MSDOS_DOTDOT, MSDOS_NAME))
|
&& strncmp((const char *)walk->dir_ent.name, MSDOS_DOTDOT,
|
||||||
if (scan_dir(fs, walk, file_cd(cp, (char*)walk->dir_ent.name)))
|
MSDOS_NAME))
|
||||||
|
if (scan_dir(fs, walk, file_cd(cp, (char *)walk->dir_ent.name)))
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/file.c
14
src/file.c
@ -75,7 +75,7 @@ char *file_name(unsigned char *fixed)
|
|||||||
*p++ = ' ';
|
*p++ = ' ';
|
||||||
put_char(&p, fixed[i]);
|
put_char(&p, fixed[i]);
|
||||||
}
|
}
|
||||||
if (strncmp((const char*)(fixed + 8), " ", 3)) {
|
if (strncmp((const char *)(fixed + 8), " ", 3)) {
|
||||||
*p++ = '.';
|
*p++ = '.';
|
||||||
for (i = j = 0; i < 3; i++)
|
for (i = j = 0; i < 3; i++)
|
||||||
if (fixed[i + 8] != ' ') {
|
if (fixed[i + 8] != ' ') {
|
||||||
@ -162,7 +162,7 @@ void file_add(char *path, FD_TYPE type)
|
|||||||
while (1) {
|
while (1) {
|
||||||
if ((here = strchr(path, '/')))
|
if ((here = strchr(path, '/')))
|
||||||
*here = 0;
|
*here = 0;
|
||||||
if (!file_cvt((unsigned char*)path, (unsigned char*)name))
|
if (!file_cvt((unsigned char *)path, (unsigned char *)name))
|
||||||
exit(2);
|
exit(2);
|
||||||
for (walk = *current; walk; walk = walk->next)
|
for (walk = *current; walk; walk = walk->next)
|
||||||
if (!here && (!strncmp(name, walk->name, MSDOS_NAME) || (type ==
|
if (!here && (!strncmp(name, walk->name, MSDOS_NAME) || (type ==
|
||||||
@ -170,8 +170,8 @@ void file_add(char *path, FD_TYPE type)
|
|||||||
&&
|
&&
|
||||||
!strncmp
|
!strncmp
|
||||||
(name + 1,
|
(name + 1,
|
||||||
walk->
|
walk->name
|
||||||
name + 1,
|
+ 1,
|
||||||
MSDOS_NAME
|
MSDOS_NAME
|
||||||
- 1))))
|
- 1))))
|
||||||
die("Ambiguous name: \"%s\"", path);
|
die("Ambiguous name: \"%s\"", path);
|
||||||
@ -245,12 +245,12 @@ void file_modify(FDSC ** curr, char *fixed)
|
|||||||
die("Internal error: file_find failed");
|
die("Internal error: file_find failed");
|
||||||
switch ((*this)->type) {
|
switch ((*this)->type) {
|
||||||
case fdt_drop:
|
case fdt_drop:
|
||||||
printf("Dropping %s\n", file_name((unsigned char*)fixed));
|
printf("Dropping %s\n", file_name((unsigned char *)fixed));
|
||||||
*(unsigned char *)fixed = DELETED_FLAG;
|
*(unsigned char *)fixed = DELETED_FLAG;
|
||||||
break;
|
break;
|
||||||
case fdt_undelete:
|
case fdt_undelete:
|
||||||
*fixed = *(*this)->name;
|
*fixed = *(*this)->name;
|
||||||
printf("Undeleting %s\n", file_name((unsigned char*)fixed));
|
printf("Undeleting %s\n", file_name((unsigned char *)fixed));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
die("Internal error: file_modify");
|
die("Internal error: file_modify");
|
||||||
@ -270,7 +270,7 @@ static void report_unused(FDSC * this)
|
|||||||
report_unused(this->first);
|
report_unused(this->first);
|
||||||
else if (this->type != fdt_none)
|
else if (this->type != fdt_none)
|
||||||
printf("Warning: did not %s file %s\n", this->type == fdt_drop ?
|
printf("Warning: did not %s file %s\n", this->type == fdt_drop ?
|
||||||
"drop" : "undelete", file_name((unsigned char*)this->name));
|
"drop" : "undelete", file_name((unsigned char *)this->name));
|
||||||
free(this);
|
free(this);
|
||||||
this = next;
|
this = next;
|
||||||
}
|
}
|
||||||
|
|||||||
8
src/io.c
8
src/io.c
@ -132,11 +132,9 @@ void fs_read(loff_t pos, int size, void *data)
|
|||||||
if (walk->pos < pos + size && walk->pos + walk->size > pos) {
|
if (walk->pos < pos + size && walk->pos + walk->size > pos) {
|
||||||
if (walk->pos < pos)
|
if (walk->pos < pos)
|
||||||
memcpy(data, (char *)walk->data + pos - walk->pos, min(size,
|
memcpy(data, (char *)walk->data + pos - walk->pos, min(size,
|
||||||
walk->
|
walk->size
|
||||||
size -
|
- pos +
|
||||||
pos +
|
walk->pos));
|
||||||
walk->
|
|
||||||
pos));
|
|
||||||
else
|
else
|
||||||
memcpy((char *)data + walk->pos - pos, walk->data,
|
memcpy((char *)data + walk->pos - pos, walk->data,
|
||||||
min(walk->size, size + pos - walk->pos));
|
min(walk->size, size + pos - walk->pos));
|
||||||
|
|||||||
@ -120,10 +120,10 @@ static char *cnv_unicode(const unsigned char *uni, int maxlen, int use_q)
|
|||||||
}
|
}
|
||||||
*cp = 0;
|
*cp = 0;
|
||||||
|
|
||||||
return (char*)out;
|
return (char *)out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void copy_lfn_part(unsigned char *dst, LFN_ENT *lfn)
|
static void copy_lfn_part(unsigned char *dst, LFN_ENT * lfn)
|
||||||
{
|
{
|
||||||
memcpy(dst, lfn->name0_4, 10);
|
memcpy(dst, lfn->name0_4, 10);
|
||||||
memcpy(dst + 10, lfn->name5_10, 12);
|
memcpy(dst + 10, lfn->name5_10, 12);
|
||||||
|
|||||||
@ -760,7 +760,7 @@ static void setup_tables(void)
|
|||||||
* :-), then 6 bytes filler (ignored), then 3 byte serial number. */
|
* :-), then 6 bytes filler (ignored), then 3 byte serial number. */
|
||||||
memcpy(bs.system_id - 1, "mkdosf", 6);
|
memcpy(bs.system_id - 1, "mkdosf", 6);
|
||||||
else
|
else
|
||||||
strcpy((char*)bs.system_id, "mkdosfs");
|
strcpy((char *)bs.system_id, "mkdosfs");
|
||||||
if (sectors_per_cluster)
|
if (sectors_per_cluster)
|
||||||
bs.cluster_size = (char)sectors_per_cluster;
|
bs.cluster_size = (char)sectors_per_cluster;
|
||||||
if (size_fat == 32) {
|
if (size_fat == 32) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user