• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <fcntl.h>
2 #include <stdint.h>
3 #include <stdio.h>
4 #include <string.h>
5 #include <termios.h>
6 #include <unistd.h>
7 #include <sys/ioctl.h>
8 #include <mtd/ubi-user.h>
9 
10 #define zero(x) memset(&x, 0, sizeof(x))
11 
main()12 int main() {
13 	int fd = open("/dev/null", 0);
14 	struct ubi_mkvol_req mkvol = {
15 		.vol_id = 3,
16 		.alignment = 124,
17 		.bytes = 1125899906842624ULL,
18 		.vol_type = 3,
19 		.name_len = 7,
20 		.name = "foobar",
21 	};
22 	struct ubi_rsvol_req rsvol = {
23 		.bytes = 1125899906842624ULL,
24 		.vol_id = -3,
25 	};
26 	struct ubi_rnvol_req rnvol = {
27 		.count = 300,
28 	};
29 	struct ubi_attach_req attach;
30 	struct ubi_map_req map;
31 	struct ubi_set_vol_prop_req prop = {
32 		.property = 1,
33 		.value = 1125899906842624ULL,
34 	};
35 	uint64_t bytes = ((uint64_t)1 << 50) | 0x123;
36 
37 	ioctl(fd, UBI_IOCMKVOL, &mkvol);
38 	ioctl(fd, UBI_IOCRSVOL, &rsvol);
39 	ioctl(fd, UBI_IOCRNVOL, &rnvol);
40 	ioctl(fd, UBI_IOCATT, &attach);
41 	ioctl(fd, UBI_IOCVOLUP, &bytes);
42 	ioctl(fd, UBI_IOCEBMAP, &map);
43 	ioctl(fd, UBI_IOCSETVOLPROP, &prop);
44 	zero(prop);
45 	ioctl(fd, UBI_IOCSETVOLPROP, &prop);
46 	ioctl(fd, UBI_IOCRMVOL, 1);
47 	ioctl(fd, UBI_IOCDET, 2);
48 	ioctl(fd, UBI_IOCEBER, 3);
49 	ioctl(fd, UBI_IOCEBCH, 4);
50 	ioctl(fd, UBI_IOCEBUNMAP, 5);
51 	ioctl(fd, UBI_IOCEBISMAP, 6);
52 
53 	return 0;
54 }
55