This article describes the sector read and write block device under Linux (example TF card), the actual application is on the Android system, the main methods are as follows: 1, find the sdcard mount point In android2.1 system should be /dev/block/mmcblk0p1, or /dev/block/mmcblk0, instead of /sdcard or /mnt/sdcard2, modify permissions, the default is no permission to read and write block devices by sector (The open handle is empty), connect the phone to the computer, enter the phone through the adb shell, set the /dev/block/mmcblk0p1 permission to 777, the command is as follows: chmod 777 -R /dev/block/mmcblk0p13, write the read and write program, The sample code is as follows int fd = open("/dev/block/mmcblk0", O_RDWR|
O_DIRECT, 606); 4, compile and install to the phone, you can directly operate on the sector. Attached to the read and write sector program (the first parameter is the file handle, the second is the read and write buffer): int WriteSectors (int fd, char * p) {//lseek (fd, 0, SEEK_SET); //if (lseek(fd, 1024, SEEK_CUR) == -1 ){//return (-1);//seek failed//}if (lseek(fd, 1024 , SEEK_SET) == -1 ){return (-1 );//seek failed} return write(fd, p, 512);}
int ReadSectors(int fd, char *p){
//lseek(fd, 0 ,SEEK_SET );//if (lseek(fd, 1024, SEEK_CUR) == -1 ){//return (-1);//seek failed//}if (lseek(fd, 1024 , SEEK_SET) == -1 ) {return (-1);//seek failed}return read(fd, p, 512);} The above send and receive buffers must conform to memory alignment: char* iobuf = NULL;
iobuf = memalign( Getpagesize(), getpagesize());//2.6version = 512;
In the existing embedded LINUX system development process, all engineers are tired
As the demand for PaaS and DevOps solutions grows, we can see that legacy applications running on v
If you want to try a desktop system other than Mac and Windows, Linux should definitely be your fir
“ A real programmer does not need an IDE. They all use a text editor with a plugin to write c
Live555 can't get ip address solution under LINUX
Linux operating system failure skills
Device model bus, driver, device basic tutorial
How to Manage KVM Virtual Environments with Command Line Tools in Linux
UDP and socket functions (binding ports)
Glusterfs cluster distributed file system off the brick processing
Linux becomes the cloud operating system
Linux kernel vulnerability (privilege escalation) instance
What should I do if the monitor is still black after the win7 computer is woken up?
Nginx how to configure gzip compression
How to prohibit Win8 from upgrading to Win8.1?
Thunder magic to solve the problem of computer poisoning black screen
What should I do if I watch the video card with iQiyi?
Microsoft Win8.1 Product Guide (Simplified Chinese) Download
How to play the Royal Sky Devils Xuan Ni How to play the Royal Sky Devils Xuan Ni play Raiders
Win8 how to delete all restore points