edd_id.c revision 17fcfb5972977b6a3aedca6ad2aa8d1fbfbc761d
/*
* edd_id - naming of BIOS disk devices via EDD
*
* Copyright (C) 2005 John Hull <John_Hull@Dell.com>
* Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*/
#ifndef _GNU_SOURCE
#define _GNU_SOURCE 1
#endif
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <dirent.h>
#include <stdint.h>
{
}
{
int i;
int export = 0;
int disk_fd;
int sysfs_fd;
int rc = 1;
goto exit;
logging_init("edd_id");
for (i = 1 ; i < argc; i++) {
export = 1;
} else
}
goto exit;
}
/* check for kernel support */
rc = 2;
goto exit;
}
if (disk_fd < 0) {
rc = 3;
goto closedir;
}
/* check for valid MBR signature */
rc = 4;
goto close;
}
rc = 5;
goto close;
}
if (mbr_valid != 0xAA55) {
rc=6;
goto close;
}
/* read EDD signature */
rc = 7;
goto close;
}
rc = 8;
goto close;
}
/* all zero is invalid */
if (disk_id == 0) {
rc = 9;
goto close;
}
/* lookup signature in sysfs to determine the name */
char file[UTIL_PATH_SIZE];
char sysfs_id_buf[256];
continue;
if (sysfs_fd < 0) {
continue;
}
if (size <= 0) {
continue;
}
/* look for matching value, that appears only once */
if (match[0] == '\0') {
/* store id */
} else {
/* error, same signature for another device */
rc = 10;
goto exit;
}
}
}
if (match[0] != '\0') {
if (export)
else
rc = 0;
}
exit:
return rc;
}