LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-16-2008, 03:21 AM   #1
advanxiang
LQ Newbie
 
Registered: May 2007
Posts: 20

Rep: Reputation: 0
mmap for device file problem?


Hi,all
In my embedded MIPS platform with kernel-2.4.25, the root filesystem is jffs2 format its size is 2048k of /dev/mtdblock1, Now , I want to write whole root filesystem via the same size as jffs2 file.it's my steps as below:
1.open device file->/dev/mtdblock1 and get file length 2048k <open/lseek>
2.map device file into virtual memory,the size is 2048k <mmap>
3.open new jffs2 root file(only file) , read its content very time with getpagesize(64k),
4.write new jffs2 content into map memory address,add one byte sizeof(char) step by step:
*pvirtualaddr++ = *pnewjffs2++;
5.munmap ,write back into file and close all resource.

sometimes,it works well and finishes re-write content,But sometimes it will write bad jffs2 inode leading not to mount root file system ,why ? and other method does this ?
Thank you .

advan
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in Open device file zvivered Linux - Kernel 7 10-10-2007 10:06 PM
mmap of a file partially present in page cache into huge pages panandsapphire Linux - Kernel 0 10-30-2006 04:31 AM
Apt Dynamic MMap problem jsburger Linux - Software 1 08-19-2006 05:24 PM
Assign one USB-storage device to one device file Misel Linux - Hardware 1 08-28-2004 03:52 AM
mmap problem os2 Programming 4 06-21-2004 05:24 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:51 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration