FreeBSD下如何访问MS-DOS文件系统( 二 )


#
# A note on permissions: a user must have read and
# write permissions for the devices named here in
# order to access the DOS file systems. You might
# give ALL USERS access to ALL FLOPPY DISKS via
#the command
#
# chmod a rw /dev/*fd* /dev/rfd[0-9]*
#
# # FreeBSD floppy drives
drive a: file="/dev/rfd0"
drive b: file="/dev/rfd1"
看来我们需要让所有的用户都有访问软驱的权限;幸运的是,指出FreeBSD软驱设备的那些行已经为我们去掉了注释,所以我们无需对此配置文件作任何更改 。

现在看一下/dev/rfd0的权限情况,因为它被mtools看作是“A:”:

ls -l /dev/rfd0
crw-r----- 18 root operator 9, 0 Oct 3 08:51 /dev/rfd0
看来这就是问题所在 。因为mtools.conf规定,用户需要rw读写权限来访问该设备,但现在用户只有r读 。由于该文件属于root,我们必需成为超级用户才能更改它的权限;因为我只有一个软驱,所以就对这个设备加入了rw权限:

su
Password:

chmod a rw /dev/rfd0

ls -l /dev/rfd0
crw-rw-rw- 18 root operator 9, 0 Oct 3 08:51 /dev/rfd0
离开超级用户账号并以普通用户身份再试一下mdir命令;你应该可以看到软盘上的内容了 。

让我们再假设一些东西 。我在自己的硬盘的起始部分有一个FAT分区;让我们来看一下mtools是否能访问它 。在mtools.conf中有一些行是关于硬盘的:

more /usr/local/etc/mtools.conf

# IDE hard disks
# first disk on the first IDE
# interface (wd0) slice 1 (s1)
drive c: file="/dev/rwd0s1"
由于我使用的FreeBSD版本高于4.0,所以其第一个IDE接口实际称为ad0而不是wd0了 。这样我需要变为超级用户并编辑一下刚才读到的行:

drive c: file="/dev/rad0s1"
^
当现在是超级用户时,我还要检查一下该设备的权限情况:

ls -l /dev/rad0s1
crw-r----- 1 root operator 116, 0x00020002 Oct 4 15:58 rad0s1
并更改一下以使用户可以访问C:盘:

chmod a rw /dev/rad0s1
然后,作为一个普通用户,来看一五我是否能访问A:盘和C:盘上的数据:

mcd a:
mdir
Volume in drive A has no label
Volume Serial Number is 3505-18E3
Directory for A:/

dru3 txt 2846 11-28-2000 21:46
inetdc~1 txt 13669 10-05-2000 21:22 inetd.conf.txt
cisco doc 10752 11-13-2000 18:07
3 files 27 267 bytes
1 428 698 bytes free
mcd c:
mdir
Volume in drive C has no label
Volume Serial Number is 39D0-A67B
Directory for C:/

bootsect bsd 512 10-04-2000 15:22
confer~1 11-01-2000 20:39 conferencing server
sybex 11-10-2000 20:18 Sybex
3 files 512 bytes
492 470 272 bytes free
现在,我知道在我的C:盘上有一些隐藏文件;如果看一下man dir的话,会知道-a开关能显示隐藏文件 。让我们再试一下:

mdir -a

Volume in drive C has no label
Volume Serial Number is 39D0-A67B
Directory for C:/

bootsect dos 512 10-04-2000 15:33
config sys 0 10-04-2000 15:40
autoexec bat 0 10-04-2000 15:40
io sys 0 10-04-2000 15:40
msdos sys 0 10-04-2000 15:40
bootsect bsd 512 10-04-2000 15:22
msdownld tmp 10-04-2000 16:10
confer~1 11-01-2000 20:39 conferencing server
recycled 11-01-2000 21:01 Recycled
sybex 11-10-2000 20:18 Sybex
arcldr exe 148992 12-07-1999 12:00
arcsetup exe 162816 12-07-1999 12:00
ntldr 214416 12-07-1999 12:00
ntdetect com 34468 11-25-2000 21:45
boot ini 214 11-25-2000 20:00
pagefile sys 104857600 11-25-2000 19:51
16 files 105 419 530 bytes
492 470 272 bytes free
再看一下我是否可以读取其中一个文件:

mtype boot.ini

[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(3)WINNT
[operating systems]
multi(0)disk(0)rdisk(0)partition(3)WINNT="Microsoft
Windows 2000 Server" /fastdetect
C:bootsect.bsd="FreeBSD"

推荐阅读