Reactos

[PSDK] ntdddisk.h, winioctl.h: Improve/sync partition types and Is[FT|Recognized]Partition() macros (#7033)

- Synchronize PARTITION_*** definitions between ntdddisk.h and winioctl.h

- Make IsFTPartition() macro definition more accurate with Win2003/Vista+
WDK definition. In particular, partition types that would conflict with
3rd-party ones are not present in this macro. (See comment in header
for more details.)
Simplify also its definition by factoring the common
((PartitionType) & PARTITION_NTFT)
piece.

- It can be recognized, in all DDK/WDK versions, that the first part of
the IsRecognizedPartition() macro definition is basically the definition
of IsFTPartition(). So, take this opportunity to simplify the definition
of IsRecognizedPartition() accordingly without losing any functionality.

+145 -140
+65 -70
sdk/include/psdk/ntdddisk.h
··· 263 263 #define SMART_SEND_DRIVE_COMMAND \ 264 264 CTL_CODE(IOCTL_DISK_BASE, 0x0021, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 265 265 266 - #define PARTITION_ENTRY_UNUSED 0x00 267 - #define PARTITION_FAT_12 0x01 268 - #define PARTITION_XENIX_1 0x02 269 - #define PARTITION_XENIX_2 0x03 270 - #define PARTITION_FAT_16 0x04 271 - #define PARTITION_EXTENDED 0x05 272 - #define PARTITION_HUGE 0x06 273 - #define PARTITION_IFS 0x07 274 - #define PARTITION_OS2BOOTMGR 0x0A 275 - #define PARTITION_FAT32 0x0B 276 - #define PARTITION_FAT32_XINT13 0x0C 277 - #define PARTITION_XINT13 0x0E 278 - #define PARTITION_XINT13_EXTENDED 0x0F 279 - #define PARTITION_MSFT_RECOVERY 0x27 280 - #define PARTITION_MAIN_OS 0x28 281 - #define PARTIITON_OS_DATA 0x29 282 - #define PARTITION_PRE_INSTALLED 0x2a 283 - #define PARTITION_BSP 0x2b 284 - #define PARTITION_DPP 0x2c 285 - #define PARTITION_WINDOWS_SYSTEM 0x2d 286 - #define PARTITION_PREP 0x41 287 - #define PARTITION_LDM 0x42 288 - #define PARTITION_DM 0x54 289 - #define PARTITION_EZDRIVE 0x55 290 - #define PARTITION_UNIX 0x63 291 - #define PARTITION_SPACES_DATA 0xD7 292 - #define PARTITION_SPACES 0xE7 293 - #define PARTITION_GPT 0xEE 294 - #define PARTITION_SYSTEM 0xEF 266 + #define PARTITION_ENTRY_UNUSED 0x00 267 + #define PARTITION_FAT_12 0x01 268 + #define PARTITION_XENIX_1 0x02 269 + #define PARTITION_XENIX_2 0x03 270 + #define PARTITION_FAT_16 0x04 271 + #define PARTITION_EXTENDED 0x05 272 + #define PARTITION_HUGE 0x06 273 + #define PARTITION_IFS 0x07 274 + #define PARTITION_OS2BOOTMGR 0x0A 275 + #define PARTITION_FAT32 0x0B 276 + #define PARTITION_FAT32_XINT13 0x0C 277 + #define PARTITION_XINT13 0x0E 278 + #define PARTITION_XINT13_EXTENDED 0x0F 279 + #define PARTITION_MSFT_RECOVERY 0x27 280 + #define PARTITION_MAIN_OS 0x28 281 + #define PARTIITON_OS_DATA 0x29 282 + #define PARTITION_PRE_INSTALLED 0x2a 283 + #define PARTITION_BSP 0x2b 284 + #define PARTITION_DPP 0x2c 285 + #define PARTITION_WINDOWS_SYSTEM 0x2d 286 + #define PARTITION_PREP 0x41 287 + #define PARTITION_LDM 0x42 288 + #define PARTITION_DM 0x54 289 + #define PARTITION_EZDRIVE 0x55 290 + #define PARTITION_UNIX 0x63 291 + #define PARTITION_SPACES_DATA 0xD7 292 + #define PARTITION_SPACES 0xE7 293 + #define PARTITION_GPT 0xEE 294 + #define PARTITION_SYSTEM 0xEF 295 295 296 - #define VALID_NTFT 0xC0 297 - #define PARTITION_NTFT 0x80 296 + #define VALID_NTFT 0xC0 297 + #define PARTITION_NTFT 0x80 298 + 298 299 #ifdef __REACTOS__ 299 - #define PARTITION_OLD_LINUX 0x43 300 - #define PARTITION_LINUX 0x83 301 - #define PARTITION_ISO9660 0x96 302 - #define PARTITION_FREEBSD 0xA5 303 - #define PARTITION_OPENBSD 0xA6 304 - #define PARTITION_NETBSD 0xA9 300 + #define PARTITION_OLD_LINUX 0x43 301 + #define PARTITION_LINUX 0x83 302 + #define PARTITION_ISO9660 0x96 303 + #define PARTITION_FREEBSD 0xA5 304 + #define PARTITION_OPENBSD 0xA6 305 + #define PARTITION_NETBSD 0xA9 305 306 #endif 306 307 307 - #define IsFTPartition( PartitionType ) \ 308 - ((((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT_12)) || \ 309 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_HUGE)) || \ 310 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_IFS)) || \ 311 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32)) || \ 312 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32_XINT13)) || \ 313 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_XINT13))) 314 - 308 + /* 309 + * NOTE: Support for partition types removed from IsFTPartition() and 310 + * IsRecognizedPartition() because they conflict with 3rd-party types: 311 + * PARTITION_NTFT | PARTITION_FAT_12 : Conflict with 0x81 "Linux or MINIX" 312 + * PARTITION_NTFT | PARTITION_FAT_16 : Conflict with 0x84 "Hibernation" 313 + * PARTITION_NTFT | PARTITION_XINT13 : Conflict with 0x8E "Linux LVM" 314 + */ 315 + #define IsFTPartition(PartitionType) \ 316 + ( ((PartitionType) & PARTITION_NTFT) && ((((PartitionType) & ~VALID_NTFT) == PARTITION_HUGE) || \ 317 + (((PartitionType) & ~VALID_NTFT) == PARTITION_IFS) || \ 318 + (((PartitionType) & ~VALID_NTFT) == PARTITION_FAT32) || \ 319 + (((PartitionType) & ~VALID_NTFT) == PARTITION_FAT32_XINT13)) ) 315 320 316 321 #define IsContainerPartition(PartitionType) \ 317 - (((PartitionType) == PARTITION_EXTENDED) || \ 318 - ((PartitionType) == PARTITION_XINT13_EXTENDED)) 322 + ( ((PartitionType) == PARTITION_EXTENDED) || \ 323 + ((PartitionType) == PARTITION_XINT13_EXTENDED) ) 319 324 320 325 #ifdef __REACTOS__ 321 - #define IsRecognizedPartition(PartitionType) ( \ 322 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT_12)) || \ 323 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_HUGE)) || \ 324 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_IFS)) || \ 325 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32)) || \ 326 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32_XINT13)) || \ 327 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_XINT13)) || \ 326 + #define IsRecognizedPartition(PartitionType) \ 327 + ( IsFTPartition(PartitionType) || \ 328 328 ((PartitionType) == PARTITION_FAT_12) || \ 329 329 ((PartitionType) == PARTITION_FAT_16) || \ 330 - ((PartitionType) == PARTITION_HUGE) || \ 331 - ((PartitionType) == PARTITION_IFS) || \ 332 - ((PartitionType) == PARTITION_FAT32) || \ 330 + ((PartitionType) == PARTITION_HUGE) || \ 331 + ((PartitionType) == PARTITION_IFS) || \ 332 + ((PartitionType) == PARTITION_FAT32) || \ 333 333 ((PartitionType) == PARTITION_FAT32_XINT13) || \ 334 334 ((PartitionType) == PARTITION_XINT13) || \ 335 - ((PartitionType) == PARTITION_LINUX) || \ 335 + ((PartitionType) == PARTITION_LINUX) || \ 336 336 ((PartitionType) == PARTITION_OLD_LINUX) || \ 337 337 ((PartitionType) == PARTITION_ISO9660) || \ 338 338 ((PartitionType) == PARTITION_FREEBSD) || \ 339 339 ((PartitionType) == PARTITION_OPENBSD) || \ 340 - ((PartitionType) == PARTITION_NETBSD)) 340 + ((PartitionType) == PARTITION_NETBSD) ) 341 341 #else 342 - #define IsRecognizedPartition(PartitionType) ( \ 343 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT_12)) || \ 344 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_HUGE)) || \ 345 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_IFS)) || \ 346 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32)) || \ 347 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_FAT32_XINT13)) || \ 348 - (((PartitionType) & PARTITION_NTFT) && (((PartitionType) & ~0xC0) == PARTITION_XINT13)) || \ 342 + #define IsRecognizedPartition(PartitionType) \ 343 + ( IsFTPartition(PartitionType) || \ 349 344 ((PartitionType) == PARTITION_FAT_12) || \ 350 345 ((PartitionType) == PARTITION_FAT_16) || \ 351 - ((PartitionType) == PARTITION_HUGE) || \ 352 - ((PartitionType) == PARTITION_IFS) || \ 353 - ((PartitionType) == PARTITION_FAT32) || \ 346 + ((PartitionType) == PARTITION_HUGE) || \ 347 + ((PartitionType) == PARTITION_IFS) || \ 348 + ((PartitionType) == PARTITION_FAT32) || \ 354 349 ((PartitionType) == PARTITION_FAT32_XINT13) || \ 355 - ((PartitionType) == PARTITION_XINT13)) 350 + ((PartitionType) == PARTITION_XINT13) ) 356 351 #endif 357 352 358 353 #if (_WIN32_WINNT >= 0x0500)
+80 -70
sdk/include/psdk/winioctl.h
··· 219 219 #define IOCTL_DISK_UPDATE_DRIVE_SIZE CTL_CODE(IOCTL_DISK_BASE, 0x0032, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS) 220 220 221 221 222 - #define PARTITION_ENTRY_UNUSED 0 223 - #define PARTITION_FAT_12 1 224 - #define PARTITION_XENIX_1 2 225 - #define PARTITION_XENIX_2 3 226 - #define PARTITION_FAT_16 4 227 - #define PARTITION_EXTENDED 5 228 - #define PARTITION_HUGE 6 229 - #define PARTITION_IFS 7 230 - #define PARTITION_FAT32 0x0B 231 - #define PARTITION_FAT32_XINT13 0x0C 232 - #define PARTITION_XINT13 0x0E 233 - #define PARTITION_XINT13_EXTENDED 0x0F 234 - #define PARTITION_PREP 0x41 235 - #define PARTITION_LDM 0x42 236 - #define PARTITION_UNIX 0x63 237 - #define PARTITION_NTFT 0x80 238 - #define VALID_NTFT 0xC0 222 + #define PARTITION_ENTRY_UNUSED 0x00 223 + #define PARTITION_FAT_12 0x01 224 + #define PARTITION_XENIX_1 0x02 225 + #define PARTITION_XENIX_2 0x03 226 + #define PARTITION_FAT_16 0x04 227 + #define PARTITION_EXTENDED 0x05 228 + #define PARTITION_HUGE 0x06 229 + #define PARTITION_IFS 0x07 230 + #define PARTITION_OS2BOOTMGR 0x0A 231 + #define PARTITION_FAT32 0x0B 232 + #define PARTITION_FAT32_XINT13 0x0C 233 + #define PARTITION_XINT13 0x0E 234 + #define PARTITION_XINT13_EXTENDED 0x0F 235 + #define PARTITION_MSFT_RECOVERY 0x27 236 + #define PARTITION_MAIN_OS 0x28 237 + #define PARTIITON_OS_DATA 0x29 238 + #define PARTITION_PRE_INSTALLED 0x2a 239 + #define PARTITION_BSP 0x2b 240 + #define PARTITION_DPP 0x2c 241 + #define PARTITION_WINDOWS_SYSTEM 0x2d 242 + #define PARTITION_PREP 0x41 243 + #define PARTITION_LDM 0x42 244 + #define PARTITION_DM 0x54 245 + #define PARTITION_EZDRIVE 0x55 246 + #define PARTITION_UNIX 0x63 247 + #define PARTITION_SPACES_DATA 0xD7 248 + #define PARTITION_SPACES 0xE7 249 + #define PARTITION_GPT 0xEE 250 + #define PARTITION_SYSTEM 0xEF 251 + 252 + #define VALID_NTFT 0xC0 253 + #define PARTITION_NTFT 0x80 254 + 239 255 #ifdef __REACTOS__ 240 - #define PARTITION_OLD_LINUX 0x43 241 - #define PARTITION_LINUX 0x83 242 - #define PARTITION_FREEBSD 0xA5 243 - #define PARTITION_OPENBSD 0xA6 244 - #define PARTITION_NETBSD 0xA9 256 + #define PARTITION_OLD_LINUX 0x43 257 + #define PARTITION_LINUX 0x83 258 + #define PARTITION_ISO9660 0x96 259 + #define PARTITION_FREEBSD 0xA5 260 + #define PARTITION_OPENBSD 0xA6 261 + #define PARTITION_NETBSD 0xA9 245 262 #endif 246 263 264 + /* 265 + * NOTE: Support for partition types removed from IsFTPartition() and 266 + * IsRecognizedPartition() because they conflict with 3rd-party types: 267 + * PARTITION_NTFT | PARTITION_FAT_12 : Conflict with 0x81 "Linux or MINIX" 268 + * PARTITION_NTFT | PARTITION_FAT_16 : Conflict with 0x84 "Hibernation" 269 + * PARTITION_NTFT | PARTITION_XINT13 : Conflict with 0x8E "Linux LVM" 270 + */ 271 + #define IsFTPartition(PartitionType) \ 272 + ( ((PartitionType) & PARTITION_NTFT) && ((((PartitionType) & ~VALID_NTFT) == PARTITION_HUGE) || \ 273 + (((PartitionType) & ~VALID_NTFT) == PARTITION_IFS) || \ 274 + (((PartitionType) & ~VALID_NTFT) == PARTITION_FAT32) || \ 275 + (((PartitionType) & ~VALID_NTFT) == PARTITION_FAT32_XINT13)) ) 276 + 277 + #define IsContainerPartition(PartitionType) \ 278 + ( ((PartitionType) == PARTITION_EXTENDED) || \ 279 + ((PartitionType) == PARTITION_XINT13_EXTENDED) ) 280 + 247 281 #ifdef __REACTOS__ 248 - #define IsRecognizedPartition(t)\ 249 - (((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT_12))||\ 250 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT_16))||\ 251 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_HUGE))||\ 252 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_IFS))||\ 253 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT32))||\ 254 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT32_XINT13))||\ 255 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_XINT13))||\ 256 - ((t)==PARTITION_FAT_12)||\ 257 - ((t)==PARTITION_FAT_16)||\ 258 - ((t)==PARTITION_HUGE)||\ 259 - ((t)==PARTITION_IFS)||\ 260 - ((t)==PARTITION_FAT32)||\ 261 - ((t)==PARTITION_FAT32_XINT13)||\ 262 - ((t)==PARTITION_XINT13)||\ 263 - ((t)==PARTITION_LINUX)||\ 264 - ((t)==PARTITION_OLD_LINUX)||\ 265 - ((t)==PARTITION_FREEBSD)||\ 266 - ((t)==PARTITION_OPENBSD)||\ 267 - ((t)==PARTITION_NETBSD)) 282 + #define IsRecognizedPartition(PartitionType) \ 283 + ( IsFTPartition(PartitionType) || \ 284 + ((PartitionType) == PARTITION_FAT_12) || \ 285 + ((PartitionType) == PARTITION_FAT_16) || \ 286 + ((PartitionType) == PARTITION_HUGE) || \ 287 + ((PartitionType) == PARTITION_IFS) || \ 288 + ((PartitionType) == PARTITION_FAT32) || \ 289 + ((PartitionType) == PARTITION_FAT32_XINT13) || \ 290 + ((PartitionType) == PARTITION_XINT13) || \ 291 + ((PartitionType) == PARTITION_LINUX) || \ 292 + ((PartitionType) == PARTITION_OLD_LINUX) || \ 293 + ((PartitionType) == PARTITION_ISO9660) || \ 294 + ((PartitionType) == PARTITION_FREEBSD) || \ 295 + ((PartitionType) == PARTITION_OPENBSD) || \ 296 + ((PartitionType) == PARTITION_NETBSD) ) 268 297 #else 269 - #define IsRecognizedPartition(t)\ 270 - (((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT_12))||\ 271 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT_16))||\ 272 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_HUGE))||\ 273 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_IFS))||\ 274 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT32))||\ 275 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT32_XINT13))||\ 276 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_XINT13))||\ 277 - ((t)==PARTITION_FAT_12)||\ 278 - ((t)==PARTITION_FAT_16)||\ 279 - ((t)==PARTITION_HUGE)||\ 280 - ((t)==PARTITION_IFS)||\ 281 - ((t)==PARTITION_FAT32)||\ 282 - ((t)==PARTITION_FAT32_XINT13)||\ 283 - ((t)==PARTITION_XINT13)) 298 + #define IsRecognizedPartition(PartitionType) \ 299 + ( IsFTPartition(PartitionType) || \ 300 + ((PartitionType) == PARTITION_FAT_12) || \ 301 + ((PartitionType) == PARTITION_FAT_16) || \ 302 + ((PartitionType) == PARTITION_HUGE) || \ 303 + ((PartitionType) == PARTITION_IFS) || \ 304 + ((PartitionType) == PARTITION_FAT32) || \ 305 + ((PartitionType) == PARTITION_FAT32_XINT13) || \ 306 + ((PartitionType) == PARTITION_XINT13) ) 284 307 #endif 285 - 286 - #define IsContainerPartition(t)\ 287 - (((t)==PARTITION_EXTENDED)||\ 288 - ((t)==PARTITION_XINT13_EXTENDED)) 289 - 290 - #define IsFTPartition(t)\ 291 - (((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT_12))||\ 292 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT_16))||\ 293 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_HUGE))||\ 294 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_IFS))||\ 295 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT32))||\ 296 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_FAT32_XINT13))||\ 297 - ((t&PARTITION_NTFT)&&((t&~VALID_NTFT)==PARTITION_XINT13))) 298 308 299 309 300 310 #define DISK_LOGGING_START 0