+ -
当前位置:首页 → 问答吧 → 直接读取磁盘,如何定位?

直接读取磁盘,如何定位?

时间:2011-06-22

来源:互联网

我希望能直接读取硬盘上的内容,不用文件方式.查了一下,大致都是说
用open("/dev/sda1", O_RDONLY);这样的方式读写.
问题
1.我试验了下,普通用户好像不能执行,是不是这个程序只能用root权限执行
2.磁盘上有些东西我想保留,如果我要写磁盘,怎么识别哪些扇区是可以写的?
fdsik -l的结果
[root@localhost code]# fdisk -l

Disk /dev/sda: 80.0 GB, 80000000000 bytes
255 heads, 63 sectors/track, 9726 cylinders, total 156250000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x90139013

  Device Boot Start End Blocks Id System
/dev/sda1 * 63 20482874 10241406 7 HPFS/NTFS
/dev/sda2 20482875 40965749 10241437+ f W95 Ext'd (LBA)
/dev/sda3 40966144 152055807 55544832 83 Linux
/dev/sda4 152055808 156248063 2096128 82 Linux swap / Solaris
/dev/sda5 20482938 40965749 10241406 7 HPFS/NTFS


df -m的结果
[root@localhost code]# df -m
文件系统 1M-块 已用 可用 已用% 挂载点
/dev/sda3 53392 11467 39213 23% /
tmpfs 496 1 496 1% /dev/shm
/dev/sda1 10002 3463 6540 35% /mnt/windows/c
/dev/sda5 10002 54 9949 1% /mnt/windows/d

作者: ssbb94   发布时间: 2011-06-22

像别的用户可以修改跟root 一样的权限,/etc/password 配置文件里,可以修改.

作者: abao623660072   发布时间: 2011-06-22

热门下载

更多