]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/udev/mtd_probe/mtd_probe.c
d5fb64f1948a31f16718c61b1227b3a3fbb474b6
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Copyright © 2010 - Maxim Levitsky
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.
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.
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
23 #include <mtd/mtd-user.h>
26 #include <sys/ioctl.h>
28 #include <sys/types.h>
31 #include "alloc-util.h"
33 #include "mtd_probe.h"
35 int main(int argc
, char** argv
) {
36 _cleanup_close_
int mtd_fd
= -1;
40 printf("usage: mtd_probe /dev/mtd[n]\n");
44 mtd_fd
= open(argv
[1], O_RDONLY
|O_CLOEXEC
|O_NOCTTY
);
46 log_error_errno(errno
, "Failed to open: %m");
50 if (ioctl(mtd_fd
, MEMGETINFO
, &mtd_info
) < 0) {
51 log_error_errno(errno
, "Failed to issue MEMGETINFO ioctl: %m");
55 if (probe_smart_media(mtd_fd
, &mtd_info
) < 0)