Thuc Hanh He Dieu Hanh 3 - ReadFloppyDisk.doc

2 479 5
Thuc Hanh He Dieu Hanh 3 - ReadFloppyDisk.doc

Đang tải... (xem toàn văn)

Thông tin tài liệu

Thuc Hanh He Dieu Hanh 3 - ReadFloppyDisk.doc

THỰC HÀNH HỆ ĐIỀU HÀNH – BÀI 3Mục tiêu : Tìm hiểu cách quản lý file và điã. Thực hành trên đĩa mềm 1.44MbBài 1 :/* The Boot sector on the floppy disk contains two things, namely, bootparameters and the disk bootstrap program. The purpose of the diskbootstrap program is to load DOS files from the disk into memory.Whether the disk bootstrap program would be used or not depends on whether the disk is being used for booting the computer or not. The boot parameters are used by DOS at the time a read or write operation is performed on the disk. This is because the boot parameters contain the vital information about how the disk has been formatted. From format to format the values of the boot parameters may change, but their order remains same. The following program display boot parameters of floppy.*//* Display boot parameters of floppy */# include "dos.h"# include "stdlib.h"# include "stdio.h"# include "conio.h"struct boot{unsigned char code[3] ;unsigned char system_id[8] ;int bytes_per_sec ;char sec_per_clus ;int res_sec ;char fat_copies ;int root_dir_entry ;unsigned int no_sects ;unsigned char format_id ;int sec_per_fat ;int sec_per_trk ; int no_sides ; int no_sp_res_sect ; unsigned char rest_code[482] ; } ; main( ){struct boot b ; char temp[4] ; int val, drive ; val = absread ( 0, 1, 0, &b ) ; if ( val == -1 ) { printf ( "Disk read Error .bad sector\n" ) ; exit ( 1 ) ; } clrscr ( ) ; printf ( "System id %s\n", b.system_id ) ; printf ( "Bytes per sector %d\n", b.bytes_per_sec ) ; printf ( "Sectors per cluster %d\n", b.sec_per_clus ) ; printf ( "Reserved sectors %d\n", b.res_sec ) ; printf ( "FAT copies %d\n", b.fat_copies ) ; printf ( "Root directory entries %d\n", b.root_dir_entry ) ; printf ( "No. of sectors on disk %u\n", b.no_sects ) ; printf ( "Format id %X\n", b.format_id ) ; printf ( "Sectors per FAT %d\n", b.sec_per_fat ) ; printf ( "Sectors per track %d\n", b.sec_per_trk ) ; printf ( "No. of sides %d\n", b.no_sides ) ; printf ( "No. of reserved sectors %d\n", b.no_sp_res_sect ) ; getch();} Bài 2 : Đọc ROOT DIR để in ra thông tin từng file trên rootBiết một entry chiếm 32 byte, có cấu trúc như sau :offset Mô tả Kích thước (byte)Kiểu dữ liệu0 Tên tập tin 8 char filename[8]8 Phần mở rộng 3 char ext[3]11 Thuộc tính 1 unsigned char12 Dự phòng 10 unsigned char[10]22 Ngày cập nhật 2 unsigned int24 Giờ cập nhật 2 unsigned int26 Cluster bắt đầu 2 unsigned int28 Kích thước tập tin 4 longBài 3 : Nhập tên file, tìm file này trên ROOT DIR và in ra các sector mà file này chiếm . bootparameters and the disk bootstrap program. The purpose of the diskbootstrap program is to load DOS files from the disk into memory.Whether the disk bootstrap. used or not depends on whether the disk is being used for booting the computer or not. The boot parameters are used by DOS at the time a read or write

Ngày đăng: 12/09/2012, 16:40

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan