aboutsummaryrefslogtreecommitdiff
path: root/ubi-utils/src/libubi_sysfs.h
blob: 2fb60727a87e42ac8b7a57f4c9a80cd736960b92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
 * Copyright (c) International Business Machines Corp., 2006
 *
 * This program is free software; you can redistribute it and/or modify
 * 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, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/*
 * UBI (Unsorted Block Images) library.
 *
 * Author: Artem B. Bityutskiy
 */

/**
 * sysfs_read_data - read data from a sysfs file.
 *
 * @file  path to the file to read from
 * @buf	  furrer where to store read data
 * @len	  length of provided buffer @buf
 *
 * This function returns the number of read bytes or -1 in case of error.
 */
int sysfs_read_data(const char *file, void *buf, int len);

/**
 * sysfs_read_data_subst - form path to a sysfs file and read data from it.
 *
 * @patt  path to the file to read from
 * @buf	  furrer where to store read data
 * @len	  length of provided buffer @buf
 * @n	  number of parameters to substitute to @patt
 *
 * This function forms path to a sysfs file by means of substituting parameters
 * to @patt and then reads @len bytes from this file and stores the read data
 * to @buf. This function returns the number of read bytes or -1 in case of
 * error.
 */
int sysfs_read_data_subst(const char *patt, void *buf, int len, int n, ...);

/**
 * sysfs_read_dev - read major and minor number from a sysfs file.
 *
 * @file   path to the file to read from
 * @major  major number is returned here
 * @minor  minor number is returned here
 */
int sysfs_read_dev(const char *file, unsigned int *major,
		unsigned int *minor);
/**
 * sysfs_read_dev_subst - for path to a file and read major and minor number
 * from it.
 *
 * @patt   pattern of the path to the file to read from
 * @major  major number is returned here
 * @minor  minor number is returned here
 * @n	   number of arguments to substitute
 *
 * This function substitures arguments to the @patt file path pattern and reads
 * major and minor numbers from the resulting file.
 */
int sysfs_read_dev_subst(const char *patt, unsigned int *major,
		unsigned int *minor, int n, ...);

/**
 * sysfs_read_ull_subst - form path to a sysfs file and read an unsigned long
 * long value from there.
 *
 * @patt  pattern of file path
 * @num	  the read value is returned here
 * @n	  number of parameters to substitute
 *
 *
 * This function first forms the path to a sysfs file by means of substituting
 * passed parameters to the @patt string, and then read an 'unsigned long long'
 * value from this file.
 */
int sysfs_read_ull_subst(const char *patt, unsigned long long *num,
		int n, ...);

/**
 * sysfs_read_uint_subst - the same as 'sysfs_read_uint_subst()' but reads an
 * unsigned int value.
 */
int sysfs_read_uint_subst(const char *patt, unsigned int *num,
		int n, ...);

/**
 * sysfs_read_ll - read a long long integer from an UBI sysfs file.
 *
 * @file  file name from where to read
 * @num	  the result is returned here
 */
int sysfs_read_ll(const char *file, long long *num);

/**
 * sysfs_read_int - the same as 'sysfs_read_ll()' but reads an 'int' value.
 */
int sysfs_read_int(const char *file, int *num);