//$ fdisk -cul /dev/sdb
//Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
//255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
//Units = sectors of 1 * 512 = 512 bytes
//Sector size (logical/physical): 512 bytes / 512 bytes
//I/O size (minimum/optimal): 512 bytes / 512 bytes
//Disk identifier: 0x790b1f29
//
// Device Boot Start End Blocks Id System
// /dev/sdb1 63 1953520064 976760001 fd Linux raid autodetect
//
// $ gcc --std=c99 -o ndi ndi.c
// $ ./ndi /dev/sdb
// $ fdisk -cul /dev/sdb
// Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
// 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
// Units = sectors of 1 * 512 = 512 bytes
// Sector size (logical/physical): 512 bytes / 512 bytes
// I/O size (minimum/optimal): 512 bytes / 512 bytes
// Disk identifier: 0xdeadbeef
//
// Device Boot Start End Blocks Id System
// /dev/sdb1 63 1953520064 976760001 fd Linux raid autodetect
#include <stdio.h>
#define NEW_DISK_IDENT 0 xDEADBEEF
#define IDENT_POSITION 0 x1B8
#define IDENT_LENGTH 4
void readDiskIdentifier(FILE* fp)
{
fseek(fp, IDENT_LENGTH - 1 + IDENT_POSITION, SEEK_SET);
for (int i = 0 ; i < IDENT_LENGTH; i++)
{
printf("%0*X" , 2 , fgetc(fp));
fseek(fp, -2 , SEEK_CUR);
}
printf("\n" );
}
void writeDiskIdentifier(FILE* fp)
{
fseek(fp, IDENT_POSITION, SEEK_SET);
for (int i = 0 ; i < IDENT_LENGTH; i++)
fputc(0 xFF & (NEW_DISK_IDENT >> i*8 ), fp);
}
int main(int argc, char **argv)
{
if (argc > 1 )
{
printf("%s\n" , argv[1 ]);
FILE* fp = fopen(argv[1 ], "r+" );
printf("Current disk identifier: " );
readDiskIdentifier(fp);
writeDiskIdentifier(fp);
printf("New disk identifier: " );
readDiskIdentifier(fp);
fclose(fp);
return 0 ;
} else
printf(" usage: %s file\n Example: %s /dev/sdb\n" , argv[0 ],
argv[0 ]);
return -2 ;
}
Messung V0.5 in Prozent C=66 H=70 G=67
¤ Dauer der Verarbeitung: 0.8 Sekunden
(vorverarbeitet am 2026-06-05)
¤
*© Formatika GbR, Deutschland