Advertisement
cubecube

utimeの実験

Nov 22nd, 2013
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. unsigned long read_value_at_address(unsigned long int address) {
  2. unsigned long value = 0;
  3. int fd;
  4. int ret;
  5. char dummy[] = "/data/local/tmp/dummy.txt";
  6. struct stat buf;
  7.  
  8. fd = open(dummy, O_CREAT, 0666);
  9. if (fd < 0) {
  10. fprintf(stderr, "open %s failed: %s.\n", dummy, strerror(errno));
  11. } else {
  12. close(fd);
  13. }
  14.  
  15. ret = utime(dummy, (struct utimbuf *)address);
  16. /* ↑これはSegmentation faultが発生する */
  17. if (ret < 0) {
  18. fprintf(stderr, "utime failed: %s.\n", strerror(errno));
  19. }
  20.  
  21. stat(dummy, &buf);
  22. value = (unsigned long)buf.st_atime;
  23.  
  24. return value;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement