OpenBSD源代码阅读/sbin/part.c
2009-05-13 06:50:26来源:未知 阅读 ()
/* $OpenBSD: part.c,v 1.42 2006/06/09 17:01:47 deraadt 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 util.h>
#include stdio.h>
#include string.h>
#include unistd.h>
#include sys/fcntl.h>
#include sys/types.h>
#include sys/stat.h>
#include sys/disklabel.h>
#include machine/param.h>
#include "disk.h"
#include "misc.h"
#include "mbr.h"
磁盘的分区表结构说明如下:
字节
说明
0
是否是活动分区:0x80表示活动分区,0x00表示普通分区
1
分区起始磁头号
2,3
2字节低6位表示起始扇区号,2字节高两位+3字节表示柱面号
4
分区文件系统标志
5,6,7
分区结束柱面号,磁头号,扇区号,意义同1,2,3相同
8,9,10,11
逻辑起始扇区号,表示在这个分区之前的扇区数
12,13,14,15
表示这个分区占用的扇区个数
void
PRT_parse(disk_t *disk, void *prt, off_t offset, off_t reloff,
prt_t *partn)
{
unsigned char *p = prt;
off_t off;
partn->flag = *p++;
partn->shead = *p++;
partn->ssect = (*p) & 0x3F;
partn->scyl = ((*p 2) & 0xFF00) | (*(p+1));
p += 2;
partn->id = *p++;
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:squid 双CPU
- sysctl编程读电池状态 2009-05-13
- 转载文章-- Windows下不安装FreeBSD轻松得到FreeBSD内核源代 2009-05-13
- 问个比较傻的问题:老版本UNIX 都哪些能弄到源代码 2009-05-13
- OpenGL实用开源代码列表 2009-05-13
- 显示驱动的源代码有没有在系统中? 2009-05-13
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash