Skip to content

Commit ae5df41

Browse files
Russell KingAl Viro
authored andcommitted
fs/adfs: dir: modernise on-disk directory structures
Use __u8 and pack the structures for on-disk directories. Signed-off-by: Russell King <[email protected]> Signed-off-by: Al Viro <[email protected]>
1 parent deed1bf commit ae5df41

File tree

2 files changed

+31
-27
lines changed

2 files changed

+31
-27
lines changed

fs/adfs/dir_f.h

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
* Directory header
1414
*/
1515
struct adfs_dirheader {
16-
unsigned char startmasseq;
17-
unsigned char startname[4];
18-
};
16+
__u8 startmasseq;
17+
__u8 startname[4];
18+
} __attribute__((packed));
1919

2020
#define ADFS_NEWDIR_SIZE 2048
2121
#define ADFS_NUM_DIR_ENTRIES 77
@@ -31,32 +31,36 @@ struct adfs_direntry {
3131
__u8 dirlen[4];
3232
__u8 dirinddiscadd[3];
3333
__u8 newdiratts;
34-
};
34+
} __attribute__((packed));
3535

3636
/*
3737
* Directory tail
3838
*/
39+
struct adfs_olddirtail {
40+
__u8 dirlastmask;
41+
char dirname[10];
42+
__u8 dirparent[3];
43+
char dirtitle[19];
44+
__u8 reserved[14];
45+
__u8 endmasseq;
46+
__u8 endname[4];
47+
__u8 dircheckbyte;
48+
} __attribute__((packed));
49+
50+
struct adfs_newdirtail {
51+
__u8 dirlastmask;
52+
__u8 reserved[2];
53+
__u8 dirparent[3];
54+
char dirtitle[19];
55+
char dirname[10];
56+
__u8 endmasseq;
57+
__u8 endname[4];
58+
__u8 dircheckbyte;
59+
} __attribute__((packed));
60+
3961
union adfs_dirtail {
40-
struct {
41-
unsigned char dirlastmask;
42-
char dirname[10];
43-
unsigned char dirparent[3];
44-
char dirtitle[19];
45-
unsigned char reserved[14];
46-
unsigned char endmasseq;
47-
unsigned char endname[4];
48-
unsigned char dircheckbyte;
49-
} old;
50-
struct {
51-
unsigned char dirlastmask;
52-
unsigned char reserved[2];
53-
unsigned char dirparent[3];
54-
char dirtitle[19];
55-
char dirname[10];
56-
unsigned char endmasseq;
57-
unsigned char endname[4];
58-
unsigned char dircheckbyte;
59-
} new;
62+
struct adfs_olddirtail old;
63+
struct adfs_newdirtail new;
6064
};
6165

6266
#endif

fs/adfs/dir_fplus.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct adfs_bigdirheader {
2222
__le32 bigdirnamesize;
2323
__le32 bigdirparent;
2424
char bigdirname[1];
25-
};
25+
} __attribute__((packed, aligned(4)));
2626

2727
struct adfs_bigdirentry {
2828
__le32 bigdirload;
@@ -32,11 +32,11 @@ struct adfs_bigdirentry {
3232
__le32 bigdirattr;
3333
__le32 bigdirobnamelen;
3434
__le32 bigdirobnameptr;
35-
};
35+
} __attribute__((packed, aligned(4)));
3636

3737
struct adfs_bigdirtail {
3838
__le32 bigdirendname;
3939
__u8 bigdirendmasseq;
4040
__u8 reserved[2];
4141
__u8 bigdircheckbyte;
42-
};
42+
} __attribute__((packed, aligned(4)));

0 commit comments

Comments
 (0)