file - Reading/Writing to Disk directly using C -


this question has answer here:

i know how read/write from/to file in c using file pointer.but want go 1 step ahead , learn how directly read/write disk partition.also difference between writing file , disk.also can manipulate content present on disk such videos,images etc.

i using c language on linux 14.04 gcc compiler.

tia.

one of nice things unix/linux systems pretty want access file.

linux has /dev filesystem has special files block , character devices. among these raw disk partitions. if run df -k, you'll see devices associated mounted filesystems.

on 1 of systems, command outputs following:

filesystem           1k-blocks      used available use% mounted on /dev/mapper/vg0-root   1040280    427008    560844  44% / /dev/mapper/vg0-var    4161216   3275900    675604  83% /var /dev/mapper/vg0-usr   30559268  14297456  14721716  50% /usr /dev/mapper/vg0-prod  30526500  11905152  17082892  42% /prod /dev/mapper/vg0-tmp    4161216    175168   3776336   5% /tmp /dev/sda1               256681     28231    215196  12% /boot 

from example, can see /var filesystem associated special file /dev/mapper/vg0-var. if open file, access raw filesystem. need understand how filesystem laid out find you're looking for.

note in order this, need root access.

warning!

it bad idea access mounted filesystem in way. os caches writes filesystem, what's physically on disk might not match os says there. writing directly filesystem in way can damage filesystem because bypassing os's caching mechanisms.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -