diff options
author | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-05-21 16:26:33 +0200 |
---|---|---|
committer | Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> | 2024-05-28 17:18:54 +0200 |
commit | 9dbd11e091f84eb0bf9d717283774816c4c4453d (patch) | |
tree | 7997b898c0a9f988b8a036ea6882b6eeb2f0995d /mdadm.h | |
parent | mdadm/tests: remove strace test (diff) | |
download | mdadm-9dbd11e091f84eb0bf9d717283774816c4c4453d.tar.xz mdadm-9dbd11e091f84eb0bf9d717283774816c4c4453d.zip |
mdadm.h: provide basename if GLIBC is not avialable
If GNU basename is not avilable, define it. It is safer to use that
rather than include libgen.h with XPG basename() definition.
Fixes:#12
Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
Diffstat (limited to 'mdadm.h')
-rw-r--r-- | mdadm.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -223,6 +223,14 @@ struct dlm_lksb { struct __una_u16 { __u16 x; } __attribute__ ((packed)); struct __una_u32 { __u32 x; } __attribute__ ((packed)); +/* + * Ensure GNU basename behavior on GLIBC less systems. + */ +#ifndef __GLIBC__ +#define basename(path) \ + (strrchr((path), '/') ? strrchr((path),'/') + 1 : (path)) +#endif + static inline __u16 __get_unaligned16(const void *p) { const struct __una_u16 *ptr = (const struct __una_u16 *)p; |