]>
Commit | Line | Data |
---|---|---|
52ad194e | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
663996b3 MS |
2 | /* |
3 | * Copyright (C) 2010 - Maxim Levitsky | |
4 | * | |
5 | * mtd_probe 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 | * mtd_probe 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 the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with mtd_probe; if not, write to the Free Software | |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, | |
18 | * Boston, MA 02110-1301 USA | |
19 | */ | |
e3bff60a | 20 | |
db2df898 MP |
21 | #include <fcntl.h> |
22 | #include <mtd/mtd-user.h> | |
663996b3 | 23 | #include <stdio.h> |
db2df898 | 24 | #include <stdlib.h> |
663996b3 | 25 | #include <sys/ioctl.h> |
663996b3 | 26 | #include <sys/stat.h> |
db2df898 | 27 | #include <sys/types.h> |
663996b3 | 28 | #include <unistd.h> |
663996b3 | 29 | |
e3bff60a MP |
30 | #include "mtd_probe.h" |
31 | ||
663996b3 MS |
32 | int main(int argc, char** argv) |
33 | { | |
34 | int mtd_fd; | |
35 | int error; | |
36 | mtd_info_t mtd_info; | |
37 | ||
38 | if (argc != 2) { | |
39 | printf("usage: mtd_probe /dev/mtd[n]\n"); | |
40 | return 1; | |
41 | } | |
42 | ||
60f067b4 | 43 | mtd_fd = open(argv[1], O_RDONLY|O_CLOEXEC); |
663996b3 MS |
44 | if (mtd_fd == -1) { |
45 | perror("open"); | |
46 | exit(-1); | |
47 | } | |
48 | ||
49 | error = ioctl(mtd_fd, MEMGETINFO, &mtd_info); | |
50 | if (error == -1) { | |
51 | perror("ioctl"); | |
52 | exit(-1); | |
53 | } | |
54 | ||
55 | probe_smart_media(mtd_fd, &mtd_info); | |
56 | return -1; | |
57 | } |