svn commit: r322969 - in head: sbin/mdconfig sys/dev/md sys/sys
Justin Hibbits
chmeeedalf at gmail.com
Tue Aug 29 19:41:14 UTC 2017
On Aug 29, 2017 14:18, "Maxim Sobolev" <sobomax at sippysoft.com> wrote:
John, OK, maybe you are right and the current status quo was just an
accident. I am curious what do you and other people think about expressing
expected structure size and padding more explicitly instead of trying to
accommodate for sometimes intricate play between alignment and type size
with something like char[N]? I.e. along the following lines:
#if __WORDSIZE < 64
#define MD_IOCTL_LEN 436
#else
#define MD_IOCTL_LEN 448
#endif
struct md_ioctl {
union {
struct _md_ioctl_payload {
unsigned version; /* Structure layout version */
unsigned unit; /* unit number */
enum md_types type ; /* type of disk */
char *file; /* pathname of file to mount */
off_t mediasize; /* size of disk in bytes */
unsigned sectorsize; /* sectorsize */
unsigned options; /* options */
u_int64_t base; /* base address */
int fwheads; /* firmware heads */
int fwsectors; /* firmware sectors */
char *label; /* label of the device */
} md;
char raw[MD_IOCTL_LEN]; /* payload + padding for future ideas */
};
};
CTASSERT(sizeof(struct md_ioctl) == MD_IOCTL_LEN);
I've tested that it DTRT on i386 and amd64, need to validate on ARM and
MIPS. The code impact should be minimal and easy to apply, i.e. ptr->md_ywz
becomes ptr->md.xyz.
I like this. Being explicit gives us better guarantees when it comes time
to break ABI, rather than it being an accident.
- Justin
More information about the svn-src-all
mailing list