t/genzipf: fix for strcasestr missing
[fio.git] / oslib / libmtd_int.h
1 /*
2  * Copyright (c) International Business Machines Corp., 2006
3  * Copyright (C) 2009 Nokia Corporation
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
13  * the GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * Author: Artem Bityutskiy
20  *
21  * MTD library.
22  */
23
24 /* Imported from mtd-utils by dehrenberg */
25
26 #ifndef __LIBMTD_INT_H__
27 #define __LIBMTD_INT_H__
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
33 #define PROGRAM_NAME "libmtd"
34
35 #define SYSFS_MTD        "class/mtd"
36 #define MTD_NAME_PATT    "mtd%d"
37 #define MTD_DEV          "dev"
38 #define MTD_NAME         "name"
39 #define MTD_TYPE         "type"
40 #define MTD_EB_SIZE      "erasesize"
41 #define MTD_SIZE         "size"
42 #define MTD_MIN_IO_SIZE  "writesize"
43 #define MTD_SUBPAGE_SIZE "subpagesize"
44 #define MTD_OOB_SIZE     "oobsize"
45 #define MTD_REGION_CNT   "numeraseregions"
46 #define MTD_FLAGS        "flags"
47
48 #define OFFS64_IOCTLS_UNKNOWN       0
49 #define OFFS64_IOCTLS_NOT_SUPPORTED 1
50 #define OFFS64_IOCTLS_SUPPORTED     2
51
52 /**
53  * libmtd - MTD library description data structure.
54  * @sysfs_mtd: MTD directory in sysfs
55  * @mtd: MTD device sysfs directory pattern
56  * @mtd_dev: MTD device major/minor numbers file pattern
57  * @mtd_name: MTD device name file pattern
58  * @mtd_type: MTD device type file pattern
59  * @mtd_eb_size: MTD device eraseblock size file pattern
60  * @mtd_size: MTD device size file pattern
61  * @mtd_min_io_size: minimum I/O unit size file pattern
62  * @mtd_subpage_size: sub-page size file pattern
63  * @mtd_oob_size: MTD device OOB size file pattern
64  * @mtd_region_cnt: count of additional erase regions file pattern
65  * @mtd_flags: MTD device flags file pattern
66  * @sysfs_supported: non-zero if sysfs is supported by MTD
67  * @offs64_ioctls: %OFFS64_IOCTLS_SUPPORTED if 64-bit %MEMERASE64,
68  *                 %MEMREADOOB64, %MEMWRITEOOB64 MTD device ioctls are
69  *                 supported, %OFFS64_IOCTLS_NOT_SUPPORTED if not, and
70  *                 %OFFS64_IOCTLS_UNKNOWN if it is not known yet;
71  *
72  *  Note, we cannot find out whether 64-bit ioctls are supported by MTD when we
73  *  are initializing the library, because this requires an MTD device node.
74  *  Indeed, we have to actually call the ioctl and check for %ENOTTY to find
75  *  out whether it is supported or not.
76  *
77  *  Thus, we leave %offs64_ioctls uninitialized in 'libmtd_open()', and
78  *  initialize it later, when corresponding libmtd function is used, and when
79  *  we actually have a device node and can invoke an ioctl command on it.
80  */
81 struct libmtd
82 {
83         char *sysfs_mtd;
84         char *mtd;
85         char *mtd_dev;
86         char *mtd_name;
87         char *mtd_type;
88         char *mtd_eb_size;
89         char *mtd_size;
90         char *mtd_min_io_size;
91         char *mtd_subpage_size;
92         char *mtd_oob_size;
93         char *mtd_region_cnt;
94         char *mtd_flags;
95         unsigned int sysfs_supported:1;
96         unsigned int offs64_ioctls:2;
97 };
98
99 int legacy_libmtd_open(void);
100 int legacy_dev_present(int mtd_num);
101 int legacy_mtd_get_info(struct mtd_info *info);
102 int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd);
103 int legacy_get_dev_info1(int dev_num, struct mtd_dev_info *mtd);
104
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif /* !__LIBMTD_INT_H__ */