D28478: [FileProtocol] change statx stat_dev() to use device major + minor
Stefan BrĂ¼ns
noreply at phabricator.kde.org
Wed Apr 1 17:36:22 BST 2020
bruns added inline comments.
INLINE COMMENTS
> file_unix.cpp:286
> inline static uint16_t stat_mode(struct statx &buf) { return buf.stx_mode; }
> -inline static uint32_t stat_dev(struct statx &buf) { return buf.stx_dev_major; }
> +inline static uint32_t stat_dev(struct statx &buf) { return (buf.stx_dev_major * 100) + buf.stx_dev_minor; }
> inline static uint64_t stat_ino(struct statx &buf) { return buf.stx_ino; }
` * 100` is definitely wrong - maybe `* 0x100`, but ...
TLDR: use `makedev`, and change the return type to dev_t.
dev_t is defined as a 64bit type atleast on Linux, which matches the 32bit major/minor parts of buf.stx_dev_*. Traditionally, major/minor are used as low/high bytes of a 16 bit type, but these can easily exhausted on a larger system. So this is was makedev does:
#define __SYSMACROS_DEFINE_MAKEDEV(DECL_TEMPL) \
__SYSMACROS_DECLARE_MAKEDEV (DECL_TEMPL) \
{ \
__dev_t __dev; \
__dev = (((__dev_t) (__major & 0x00000fffu)) << 8); \
__dev |= (((__dev_t) (__major & 0xfffff000u)) << 32); \
__dev |= (((__dev_t) (__minor & 0x000000ffu)) << 0); \
__dev |= (((__dev_t) (__minor & 0xffffff00u)) << 12); \
return __dev; \
}
REPOSITORY
R241 KIO
REVISION DETAIL
https://phabricator.kde.org/D28478
To: ahmadsamir, #frameworks, dfaure, meven
Cc: bruns, kde-frameworks-devel, LeGast00n, cblack, GB_2, michaelh, ngraham
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20200401/c87e55bf/attachment-0001.html>
More information about the Kde-frameworks-devel
mailing list