devinfo_devlink.h revision 74ceea2d43ae370f7678d3f98ea3e47fde931098
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _DEVINFO_DEVLINK_H
#define _DEVINFO_DEVLINK_H
#ifdef __cplusplus
extern "C" {
#endif
#define _POSIX_PTHREAD_SEMANTICS /* For readdir_r */
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <thread.h>
#include <synch.h>
#include <libdevinfo.h>
#include <limits.h>
#include <stdlib.h>
#include <dirent.h>
#include <regex.h>
#include <errno.h>
#include <stdarg.h>
#include <door.h>
#include <signal.h>
struct db_link {
};
struct db_minor {
};
struct db_node {
};
typedef enum db_seg {
DB_NODE = 0,
DB_TYPES, /* Number of non-header segments */
} db_seg_t;
struct db_hdr {
};
typedef struct cache_link {
char *path; /* link path */
char *content; /* link content */
} cache_link_t;
typedef struct cache_minor {
char *name; /* minor name */
char *nodetype; /* minor nodetype */
typedef struct cache_node {
char *path; /* path */
} cache_node_t;
struct cache {
};
struct db {
int db_fd; /* database file */
};
struct di_devlink_handle {
char *dev_dir; /* <root-dir>/dev */
int lock_fd; /* lock file for updates */
};
typedef struct link_desc {
const char *minor_path;
void *arg;
int (*fcn)(di_devlink_t, void *);
int retval;
} link_desc_t;
struct tnode {
void *node;
int flags;
struct di_devlink_handle *handle;
};
struct di_devlink {
char *rel_path;
char *abs_path;
char *content;
int type;
};
typedef struct recurse {
void *data;
int (*fcn)(struct di_devlink_handle *, void *, const char *);
} recurse_t;
/*
* Debug levels currently defined.
*/
typedef enum {
DBG_ERR = 1,
#define DB_MAGIC 0xBAC2ACAB
#define DB_FILE ".devlink_db"
#define DB_TMP ".devlink_db_tmp"
#define DB_LOCK ".devlink_db_lock"
#define DB_LOCK_PERMS DB_PERMS
#define DB_VERSION 1
#define DB_NIL 0
#define DEV "/dev"
#define DEVICES_SUFFIX "ices"
/*
* Various flags private to the implementation
*/
#define A_PRIMARY 0x0001U
#define A_SECONDARY 0x0002U
#define A_VALID 0x0004U
#define TYPE_DB 0x0008U
#define TYPE_CACHE 0x0010U
#define CREATE_FLAG 0x0020U
#define INSERT_HEAD 0x0040U
#define INSERT_TAIL 0x0080U
#define OPEN_RDWR 0x0100U
#define OPEN_RDONLY 0x0200U
#define UNLINK_FROM_HASH 0x0400U
#define SET_VALID_ATTR(a) ((a) |= A_VALID)
#define CLR_VALID_ATTR(a) ((a) &= ~A_VALID)
#define GET_VALID_ATTR(a) ((a) & A_VALID)
#define LOOKUP_CACHE(f) ((f) & TYPE_CACHE)
#define CREATE_ELEM(f) ((f) & CREATE_FLAG)
#define TYPE_NONE(f) (((f) & DI_LINK_TYPES) == 0)
#define LINK_TYPE(f) ((f) & DI_LINK_TYPES)
/*
* Environment variables used by DEBUG version of code.
*/
#define SKIP_DB "DEBUG_SKIP_DB"
#define SKIP_LAST_CACHE "DEBUG_SKIP_LAST_CACHE"
#define ALT_DB_DIR "DEBUG_ALT_DB_DIR"
/*
* Function prototypes
*/
cache_minor_t **prev);
const int flags);
link_desc_t *linkp);
struct di_devlink *vlp);
link_desc_t *linkp);
link_desc_t *linkp);
const char *link_path);
int flags);
int flags);
static char *minor_colon(const char *path);
cache_link_t *clp);
#ifdef __cplusplus
}
#endif
#endif /* _DEVINFO_DEVLINK_H */