danielhilst

mtdinfo.c

Oct 2nd, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <fcntl.h>
  3. #include <sys/ioctl.h>
  4. #include <mtd/mtd-user.h>
  5.  
  6. int main(int argc, char **argv)
  7. {
  8.     mtd_info_t mtd_info;
  9.     int fd;
  10.  
  11.     if (argc < 2) {
  12.             fprintf(stderr, "usage: %s /dev/mtdDEVICE\n", argv[0]);
  13.             return -1;
  14.     }
  15.  
  16.     fd = open(argv[1], O_RDWR);
  17.     ioctl(fd, MEMGETINFO, &mtd_info);
  18.  
  19.     printf("MTD type: %u\n", mtd_info.type);
  20.     printf("MTD total size : %u %1$xh bytes\n", mtd_info.size);
  21.     printf("MTD erase size : %u %1$xh bytes\n", mtd_info.erasesize);
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment