/* * Some of the MPLE magic bytes are set from the media serial number * in the FAT header. This data is not accessible to non-root * users. This is a small helper program to read the data. Note, it * can read arbitrary devices, but only 4 bytes at 0x27. */ #include #include #include #include #include "mple.h" /* this is the allowed device prefix. anything else will be rejected */ #define DEVICE_PREFIX "/dev/sd" int main( int argc, char *argv[] ) { mple_device device; if (( argc != 2 ) || strncmp( argv[1], DEVICE_PREFIX, strlen( DEVICE_PREFIX ))) { fprintf( stderr, "usage: %s %s...\n", argv[0], DEVICE_PREFIX ); return 1; } memset( &device, 0, sizeof( device )); device.device = g_strdup( argv[1] ); errno = 0; if ( mple_get_media_serial_number( &device )) { printf( "%08x\n", device.msn ); return 0; } else { perror( "get_msn" ); return 1; } }