goroh_kun

mkdevsh.c

Aug 2nd, 2012
1,044
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <sys/mount.h>
  2. #include <fcntl.h>
  3.  
  4. static void filecopy(const char* src, const char* dst, int mode)
  5. {
  6.     char buf[0x1000];
  7.    int ret;
  8.     int fd = open(dst, O_WRONLY | O_CREAT);
  9.     int fd2 = open(src, O_RDONLY);
  10.     int len;
  11.     while((len = read(fd2, buf, sizeof(buf))) !=0) {
  12.         write(fd, buf, len);
  13.     }
  14.     close(fd);
  15.     close(fd2);
  16.     ret = chmod(dst, mode);
  17. }
  18.  
  19.  
  20. int main(int argc, const char**argv)
  21. {
  22.         mount("/dev", "/dev",  0, MS_REMOUNT, 0);
  23.         chmod("/data", 0777);
  24.         filecopy("/system/bin/sh", "/dev/sh", 06755);
  25.         return 0;
  26. }
RAW Paste Data