edd_id.c revision 1aa1e24848903d11780db1ade355be73ad61a937
/*
* 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>
#include "../../udev.h"
#ifdef USE_LOG
{
static int udev_log = -1;
if (udev_log == -1) {
const char *value;
if (value)
else
}
return;
}
#endif
{
int i;
int export = 0;
int disk_fd;
int sysfs_fd;
int rc = 1;
logging_init("edd_id");
for (i = 1 ; i < argc; i++) {
export = 1;
} else
}
if (!node) {
err("no node specified");
goto exit;
}
/* check for kernel support */
if (!dir) {
info("no kernel EDD 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 sysfs_id_buf[256];
continue;
if (sysfs_fd < 0) {
continue;
}
if (size < 0) {
continue;
}
if (!match) {
} else {
rc=10;
goto exit;
}
}
}
if (export)
else
rc = 0;
exit:
return rc;
}