Skip to content

Commit

Permalink
vvfat: add constants for special values of name[0]
Browse files Browse the repository at this point in the history
Signed-off-by: Hervé Poussineau <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
hpoussin authored and kevmw committed Jul 18, 2017
1 parent 208c38e commit 8c4517f
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions block/vvfat.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ void nonono(const char* file, int line, const char* msg) {

#endif

#define DIR_DELETED 0xe5
#define DIR_KANJI DIR_DELETED
#define DIR_KANJI_FAKE 0x05
#define DIR_FREE 0x00

/* dynamic array functions */
typedef struct array_t {
char* pointer;
Expand Down Expand Up @@ -466,7 +471,7 @@ static direntry_t *create_long_filename(BDRVVVFATState *s, const char *filename)

static char is_free(const direntry_t* direntry)
{
return direntry->name[0]==0xe5 || direntry->name[0]==0x00;
return direntry->name[0] == DIR_DELETED || direntry->name[0] == DIR_FREE;
}

static char is_volume_label(const direntry_t* direntry)
Expand All @@ -487,7 +492,7 @@ static char is_short_name(const direntry_t* direntry)

static char is_directory(const direntry_t* direntry)
{
return direntry->attributes & 0x10 && direntry->name[0] != 0xe5;
return direntry->attributes & 0x10 && direntry->name[0] != DIR_DELETED;
}

static inline char is_dot(const direntry_t* direntry)
Expand Down Expand Up @@ -589,8 +594,8 @@ static direntry_t *create_short_filename(BDRVVVFATState *s,
}
}

if (entry->name[0] == 0xe5) {
entry->name[0] = 0x05;
if (entry->name[0] == DIR_KANJI) {
entry->name[0] = DIR_KANJI_FAKE;
}

/* numeric-tail generation */
Expand Down Expand Up @@ -1748,8 +1753,8 @@ static int parse_short_name(BDRVVVFATState* s,
} else
lfn->name[i + j + 1] = '\0';

if (lfn->name[0] == 0x05) {
lfn->name[0] = 0xe5;
if (lfn->name[0] == DIR_KANJI_FAKE) {
lfn->name[0] = DIR_KANJI;
}
lfn->len = strlen((char*)lfn->name);

Expand Down

0 comments on commit 8c4517f

Please sign in to comment.