From 123d4de40dd96c1e720b1e87a6b17d362cc244ce Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 16 Sep 2024 14:27:15 +0200 Subject: [PATCH] include/blkdev: share BLKDISCARD macros Move BLKDISCARD* ioctl identifiers to the include/blkdev.h file to prevent duplicate definitions. Signed-off-by: Karel Zak --- disk-utils/fdisk.c | 3 --- include/blkdev.h | 12 +++++++++++- sys-utils/blkdiscard.c | 13 +------------ 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 2500c142dc..962eb5ae7f 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -59,9 +59,6 @@ # ifdef HAVE_LINUX_FS_H # include # endif -# ifndef BLKDISCARD -# define BLKDISCARD _IO(0x12,119) -# endif #endif int pwipemode = WIPEMODE_AUTO; diff --git a/include/blkdev.h b/include/blkdev.h index efa33af11f..3f3c5e2ab6 100644 --- a/include/blkdev.h +++ b/include/blkdev.h @@ -59,6 +59,17 @@ # define BLKPBSZGET _IO(0x12,123) # endif +/* discard area on a device */ +#ifndef BLKDISCARD +# define BLKDISCARD _IO(0x12,119) +#endif +#ifndef BLKSECDISCARD +# define BLKSECDISCARD _IO(0x12,125) +#endif +#ifndef BLKZEROOUT +# define BLKZEROOUT _IO(0x12,127) +#endif + /* discard zeroes support, introduced in 2.6.33 (commit 98262f27) */ # ifndef BLKDISCARDZEROES # define BLKDISCARDZEROES _IO(0x12,124) @@ -79,7 +90,6 @@ # ifndef CDROM_GET_CAPABILITY # define CDROM_GET_CAPABILITY 0x5331 # endif - #endif /* __linux */ diff --git a/sys-utils/blkdiscard.c b/sys-utils/blkdiscard.c index 16c32e6e57..fc57aeb73b 100644 --- a/sys-utils/blkdiscard.c +++ b/sys-utils/blkdiscard.c @@ -48,18 +48,7 @@ #include "closestream.h" #include "monotonic.h" #include "exitcodes.h" - -#ifndef BLKDISCARD -# define BLKDISCARD _IO(0x12,119) -#endif - -#ifndef BLKSECDISCARD -# define BLKSECDISCARD _IO(0x12,125) -#endif - -#ifndef BLKZEROOUT -# define BLKZEROOUT _IO(0x12,127) -#endif +#include "blkdev.h" enum { ACT_DISCARD = 0, /* default */ -- 2.47.2