/[soft]/ldetect/trunk/libsysfs.h
ViewVC logotype

Contents of /ldetect/trunk/libsysfs.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1357 - (show annotations) (download)
Tue May 17 09:21:22 2011 UTC (10 years ago) by dmorgan
File MIME type: text/plain
File size: 2727 byte(s)
Import  ldetect
1 /*
2 * libsysfs.h
3 *
4 * Header Definitions for libsysfs
5 *
6 * Copyright (C) IBM Corp. 2004-2005
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12 *
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
23 #ifndef _LIBSYSFS_H_
24 #define _LIBSYSFS_H_
25
26 #include <sys/types.h>
27 #include <string.h>
28
29 #define SYSFS_FSTYPE_NAME "sysfs"
30 #define SYSFS_PROC_MNTS "/proc/mounts"
31 #define SYSFS_BUS_NAME "bus"
32 #define SYSFS_CLASS_NAME "class"
33 #define SYSFS_BLOCK_NAME "block"
34 #define SYSFS_DEVICES_NAME "devices"
35 #define SYSFS_DRIVERS_NAME "drivers"
36 #define SYSFS_MODULE_NAME "module"
37 #define SYSFS_NAME_ATTRIBUTE "name"
38 #define SYSFS_MOD_PARM_NAME "parameters"
39 #define SYSFS_MOD_SECT_NAME "sections"
40 #define SYSFS_UNKNOWN "unknown"
41 #define SYSFS_PATH_ENV "SYSFS_PATH"
42
43 #define SYSFS_PATH_MAX 256
44 #define SYSFS_NAME_LEN 64
45 #define SYSFS_BUS_ID_SIZE 32
46
47 /* mount path for sysfs, can be overridden by exporting SYSFS_PATH */
48 #define SYSFS_MNT_PATH "/sys"
49
50 enum sysfs_attribute_method {
51 SYSFS_METHOD_SHOW = 0x01, /* attr can be read by user */
52 SYSFS_METHOD_STORE = 0x02, /* attr can be changed by user */
53 };
54
55 /*
56 * NOTE:
57 * 1. We have the statically allocated "name" as the first element of all
58 * the structures. This feature is used in the "sorter" function for dlists
59 * 2. As is the case with attrlist
60 * 3. As is the case with path
61 */
62 struct sysfs_attribute {
63 char name[SYSFS_NAME_LEN];
64 char path[SYSFS_PATH_MAX];
65 char *value;
66 unsigned short len; /* value length */
67 enum sysfs_attribute_method method; /* show and store */
68 };
69
70 #ifdef __cplusplus
71 extern "C" {
72 #endif
73
74 /*
75 * Function Prototypes
76 */
77 extern int sysfs_get_name_from_path(const char *path, char *name, size_t len);
78
79 /* sysfs directory and file access */
80 extern void sysfs_close_attribute(struct sysfs_attribute *sysattr);
81 extern struct sysfs_attribute *sysfs_open_attribute(const char *path);
82 extern int sysfs_read_attribute(struct sysfs_attribute *sysattr);
83 extern int sysfs_write_attribute(struct sysfs_attribute *sysattr,
84 const char *new_value, size_t len);
85
86 #ifdef __cplusplus
87 }
88 #endif
89
90 #endif /* _LIBSYSFS_H_ */

Properties

Name Value
svn:eol-style native

  ViewVC Help
Powered by ViewVC 1.1.28