Messages in this thread | | | Subject | Re: [PATCH v2] drivers/cdrom: improved ioctl for media change detection | From | Randy Dunlap <> | Date | Thu, 9 Sep 2021 18:25:35 -0700 |
| |
On 9/9/21 11:05 AM, Lukas Prediger wrote: >>> As this is not a packed struct, would not a smaller value still take up >>> the same space? >> Might as well be explicit about it and also make it obvious that there >> is some space available for other fields. > I had this as a __u8 in the first submission but Jens asked me to change it. > From his feedback on this: > > "The struct layout should be modified such that there are no holes or > padding in it. Probably just make the has_changed a flags thing, and > make it u64 as well. Then you can define bit 0 to be HAS_CHANGED, and > that leaves you room to add more flags in the future." > https://lore.kernel.org/lkml/6d6c533d-465e-33ee-5801-cb7ea84924a8@kernel.dk/ > > I changed it to __u64 to address this. We could think about turning it > back to a __u8 (or bool) and add some explicit padding members > (a __u8 reserved[3]?), but honestly I don't see much real benefit in that > compared to how it is now.
I have no problem with Jens's suggestion. It would look more like this:
+{ + __s64 last_media_change; /* Timestamp of the last detected media + * change in ms. May be set by caller, updated + * upon successful return of ioctl. + */ + __u64 media_flags; /* various <struct> flags */
#define MEDIA_CHANGED 0x1 /* Set to 1 by ioctl if last detected media */ /* other bits of media_flags available for future use */
and not having __u64 has_changed; which is overkill for a flag.
-- ~Randy
| |