]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/udev/mtd_probe/mtd_probe.c
tree-wide: sort includes
[thirdparty/systemd.git] / src / udev / mtd_probe / mtd_probe.c
CommitLineData
674c3412 1/*
674c3412
ML
2 * Copyright (C) 2010 - Maxim Levitsky
3 *
4 * mtd_probe is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * mtd_probe is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with mtd_probe; if not, write to the Free Software
5f307a98 16 * Foundation, Inc., 51 Franklin St, Fifth Floor,
674c3412
ML
17 * Boston, MA 02110-1301 USA
18 */
885fdebc 19
cf0fbc49
TA
20#include <fcntl.h>
21#include <mtd/mtd-user.h>
674c3412 22#include <stdio.h>
cf0fbc49 23#include <stdlib.h>
674c3412 24#include <sys/ioctl.h>
674c3412 25#include <sys/stat.h>
cf0fbc49 26#include <sys/types.h>
674c3412 27#include <unistd.h>
674c3412 28
885fdebc
LP
29#include "mtd_probe.h"
30
5f307a98
KS
31int main(int argc, char** argv)
32{
fc863dea
KS
33 int mtd_fd;
34 int error;
35 mtd_info_t mtd_info;
36
912541b0
KS
37 if (argc != 2) {
38 printf("usage: mtd_probe /dev/mtd[n]\n");
39 return 1;
40 }
674c3412 41
c8a202b7 42 mtd_fd = open(argv[1], O_RDONLY|O_CLOEXEC);
912541b0
KS
43 if (mtd_fd == -1) {
44 perror("open");
45 exit(-1);
46 }
674c3412 47
fc863dea 48 error = ioctl(mtd_fd, MEMGETINFO, &mtd_info);
912541b0
KS
49 if (error == -1) {
50 perror("ioctl");
51 exit(-1);
52 }
674c3412 53
912541b0
KS
54 probe_smart_media(mtd_fd, &mtd_info);
55 return -1;
674c3412 56}