path_id.c revision 48a9b173e88738ff4eefb3519f1d27711b417c8d
/*
* compose persisistent device path
*
* Copyright (C) 2009 Kay Sievers <kay.sievers@vrfy.org>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <errno.h>
#include <dirent.h>
#include <getopt.h>
#include "libudev.h"
int debug;
{
if (debug) {
} else {
}
}
{
char *old;
char *pre;
int err;
if (err < 0)
return err;
if (err < 0)
return err;
} else {
}
return 0;
}
{
const char *subsystem;
break;
}
return dev;
}
{
struct udev_device *targetdev;
const char *port;
unsigned int lun;
return NULL;
fcdev = udev_device_new_from_subsystem_sysname(udev, "fc_transport", udev_device_get_sysname(targetdev));
return NULL;
goto out;
}
out:
return parent;
}
{
return NULL;
}
{
struct udev_device *transportdev;
const char *target;
char *connname;
const char *addr;
const char *port;
/* find iscsi session */
while (1) {
if (transportdev == NULL)
return NULL;
break;
}
if (transportdev == NULL)
return NULL;
/* find iscsi session device */
sessiondev = udev_device_new_from_subsystem_sysname(udev, "iscsi_session", udev_device_get_sysname(transportdev));
if (sessiondev == NULL)
return NULL;
goto out;
}
goto out;
}
goto out;
}
goto out;
}
out:
return parent;
}
{
struct udev_device *hostdev;
const char *name;
char *base;
char *pos;
int basenum;
return NULL;
return NULL;
/* rebase host offset to get the local relative number */
basenum = -1;
return NULL;
goto out;
}
pos[0] = '\0';
goto out;
}
char *rest;
int i;
continue;
continue;
continue;
if (rest[0] != '\0')
continue;
basenum = i;
}
if (basenum == -1) {
goto out;
}
out:
return hostdev;
}
{
const char *devtype;
const char *name;
const char *id;
return parent;
/* firewire */
goto out;
}
/* lousy scsi sysfs does not have a "subsystem" for the transport */
goto out;
}
goto out;
}
goto out;
}
out:
return parent;
}
{
const char *name;
}
{
const char *devtype;
const char *str;
const char *port;
return parent;
return parent;
port++;
return parent;
}
{
return NULL;
}
static struct udev_device *handle_ccw(struct udev_device *parent, struct udev_device *dev, char **path)
{
struct udev_device *scsi_dev;
const char *wwpn;
const char *lun;
const char *hba_id;
goto out;
}
}
out:
return parent;
}
{
{}
};
struct udev_device *dev;
struct udev_device *parent;
char syspath[UTIL_PATH_SIZE];
const char *devpath;
char *path;
char *path_suffix;
int rc = 1;
goto exit;
logging_init("path_id");
while (1) {
int option;
if (option == -1)
break;
switch (option) {
case 'd':
debug = 1;
break;
case 'h':
printf("Usage: path_id [--debug] [--help] <devpath>\n"
" --debug print debug information\n"
" --help print this help text\n\n");
default:
rc = 1;
goto exit;
}
}
rc = 2;
goto exit;
}
rc = 3;
goto exit;
}
path_suffix = NULL;
/* S390 ccw bus */
goto out;
}
/* walk up the chain of devices and compose path */
const char *subsys;
;
}
}
out:
if (path_suffix != NULL) {
} else {
}
rc = 0;
}
exit:
return rc;
}