OpenBSD源代码阅读/sbin/mbr.c

2009-05-13 06:48:42来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折


                               
               
               
                /*    $OpenBSD: mbr.c,v 1.22 2006/05/29 05:09:36 ray Exp $    */
/*
* Copyright (c) 1997 Tobias Weingartner
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
*    notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
*    notice, this list of conditions and the following disclaimer in the
*    documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include err.h>
#include errno.h>
#include util.h>
#include stdio.h>
#include unistd.h>
#include memory.h>
#include sys/fcntl.h>
#include sys/ioctl.h>
#include sys/types.h>
#include sys/stat.h>
#include sys/disklabel.h>
#include sys/dkio.h>
#include machine/param.h>
#include "disk.h"
#include "misc.h"
#include "mbr.h"
#include "part.h"
mbr_t结构定义在mbr.h中,如下:
typedef struct _mbr_t {
    off_t reloffset;
    off_t offset;
    unsigned char code[MBR_CODE_SIZE]; mbr的代码
    prt_t part[NDOSPART]; 磁盘分区表的结构
NDOSPART=4,定义在src/sys/arch/i386/include/disklabe.h中
prt_t 为分区表的结构,定义在part.h中,如下:
/* Partition type */typedef struct _prt_t {    u_int32_t shead, scyl, ssect; 开始的磁头号shead,柱面scyl,扇区ssect    u_int32_t ehead, ecyl, esect; 结束的磁头号shead,柱面scyl,扇区ssect    u_int32_t bs; 由shead, scyl, ssect计算的开始扇区,begin sector的缩写    u_int32_t ns; 分区占用的扇区的数量,number sector的缩写    unsigned char flag; 是否是活动分区的标志    unsigned char id; 分区的类型的ID编号} prt_t;

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:freebsd服务器托管一般性设置

下一篇:make world