亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ldm.c

?? ARM 嵌入式 系統 設計與實例開發 實驗教材 二源碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* * ldm - Part of the Linux-NTFS project. * * Copyright (C) 2001 Richard Russon <ldm@flatcap.org> * Copyright (C) 2001 Anton Altaparmakov <antona@users.sf.net> (AIA) * * Documentation is available at http://linux-ntfs.sf.net/ldm * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program (in the main directory of the Linux-NTFS source * in the file COPYING); if not, write to the Free Software Foundation, * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA * * 28/10/2001 - Added sorting of ldm partitions. (AIA) */#include <linux/types.h>#include <asm/unaligned.h>#include <asm/byteorder.h>#include <linux/genhd.h>#include <linux/blkdev.h>#include <linux/slab.h>#include "check.h"#include "ldm.h"#include "msdos.h"#if 0 /* Fool kernel-doc since it doesn't do macros yet. *//** * ldm_debug - output an error message if debugging was enabled at compile time * @f:		a printf format string containing the message * @...:	the variables to substitute into @f * * ldm_debug() writes a DEBUG level message to the syslog but only if the * driver was compiled with debug enabled. Otherwise, the call turns into a NOP. */static void ldm_debug(const char *f, ...);#endif#ifdef CONFIG_LDM_DEBUG#define ldm_debug(f, a...)						\	{								\		printk(LDM_DEBUG " DEBUG (%s, %d): %s: ",		\				__FILE__, __LINE__, __FUNCTION__);	\		printk(f, ##a);						\	}#else	/* !CONFIG_LDM_DEBUG */#define ldm_debug(f, a...)	do {} while (0)#endif	/* !CONFIG_LDM_DEBUG *//* Necessary forward declarations. */static int create_partition(struct gendisk *, int, int, int);static int parse_privhead(const u8 *, struct privhead *);static u64 get_vnum(const u8 *, int *);static int get_vstr(const u8 *, u8 *, const int);/** * parse_vblk_part - parse a LDM database vblk partition record * @buffer:	vblk partition record loaded from the LDM database * @buf_size:	size of @buffer in bytes * @vb:		in memory vblk structure to return parsed information in * * This parses the LDM database vblk record of type VBLK_PART, i.e. a partition * record, supplied in @buffer and sets up the in memory vblk structure @vb * with the obtained information. * * Return 1 on success and -1 on error, in which case @vb is undefined. */static int parse_vblk_part(const u8 *buffer, const int buf_size,		struct vblk *vb){	int err, rel_objid, rel_name, rel_size, rel_parent;	if (0x34 >= buf_size)		return -1;	/* Calculate relative offsets. */	rel_objid  = 1 + buffer[0x18];	if (0x18 + rel_objid >= buf_size)		return -1;	rel_name   = 1 + buffer[0x18 + rel_objid] + rel_objid;	if (0x34 + rel_name >= buf_size)		return -1;	rel_size   = 1 + buffer[0x34 + rel_name] + rel_name;	if (0x34 + rel_size >= buf_size)		return -1;	rel_parent = 1 + buffer[0x34 + rel_size] + rel_size;	if (0x34 + rel_parent >= buf_size)		return -1;	/* Setup @vb. */	vb->vblk_type    = VBLK_PART;	vb->obj_id       = get_vnum(buffer + 0x18, &err);	if (err || 0x34 + rel_parent + buffer[0x34 + rel_parent] >= buf_size)		return -1;	vb->disk_id      = get_vnum(buffer + 0x34 + rel_parent, &err);	if (err || 0x24 + rel_name + 8 > buf_size)		return -1;	vb->start_sector = BE64(buffer + 0x24 + rel_name);	if (0x34 + rel_name + buffer[0x34 + rel_name] >= buf_size)		return -1;	vb->num_sectors  = get_vnum(buffer + 0x34 + rel_name, &err);	if (err || 0x18 + rel_objid + buffer[0x18 + rel_objid] >= buf_size)		return -1;	err = get_vstr(buffer + 0x18 + rel_objid, vb->name, sizeof(vb->name));	if (err == -1)		return err;	ldm_debug("Parsed Partition VBLK successfully.\n");	return 1;}/** * parse_vblk - parse a LDM database vblk record * @buffer:	vblk record loaded from the LDM database * @buf_size:	size of @buffer in bytes * @vb:		in memory vblk structure to return parsed information in * * This parses the LDM database vblk record supplied in @buffer and sets up * the in memory vblk structure @vb with the obtained information. * * Return 1 on success, 0 if successful but record not in use, and -1 on error. * If the return value is 0 or -1, @vb is undefined. * * NOTE: Currently the only record type we handle is VBLK_PART, i.e. records * describing a partition. For all others, we just set @vb->vblk_type to 0 and * return success. This of course means that if @vb->vblk_type is zero, all * other fields in @vb are undefined. */static int parse_vblk(const u8 *buffer, const int buf_size, struct vblk *vb){	int err = 1;	if (buf_size < 0x14)		return -1;	if (MAGIC_VBLK != BE32(buffer)) {		printk(LDM_CRIT "Cannot find VBLK, database may be corrupt.\n");		return -1;	}	if ((BE16(buffer + 0x0E) == 0) ||       /* Record is not in use. */	    (BE16(buffer + 0x0C) != 0))         /* Part 2 of an ext. record */		return 0;	/* FIXME: What about extended VBLKs? */	switch (buffer[0x13]) {	case VBLK_PART:		err = parse_vblk_part(buffer, buf_size, vb);		break;	default:		vb->vblk_type = 0;	}	if (err != -1)		ldm_debug("Parsed VBLK successfully.\n");	return err;}/** * add_partition_to_list - insert partition into a partition list * @pl:		sorted list of partitions * @hd:		gendisk structure to which the data partition belongs * @disk_minor:	minor number of the disk device * @start:	first sector within the disk device * @size:	number of sectors on the partition device * * This sanity checks the partition specified by @start and @size against the * device specified by @hd and inserts the partition into the sorted partition * list @pl if the checks pass. * * On success return 1, otherwise return -1. * * TODO: Add sanity check for overlapping partitions. (AIA) */ static int add_partition_to_list(struct list_head *pl, const struct gendisk *hd,		const int disk_minor, const unsigned long start,		const unsigned long size){	struct ldm_part *lp, *lptmp;	struct list_head *tmp;	if (!hd->part)		return -1;	if ((start < 1) || ((start + size) > hd->part[disk_minor].nr_sects)) {		printk(LDM_CRIT "LDM partition exceeds physical disk. "				"Skipping.\n");		return -1;	}	lp = (struct ldm_part*)kmalloc(sizeof(struct ldm_part), GFP_KERNEL);	if (!lp) {		printk(LDM_CRIT "Not enough memory! Aborting LDM partition "				"parsing.\n");		return -2;	}	INIT_LIST_HEAD(&lp->part_list);	lp->start = start;	lp->size = size;	list_for_each(tmp, pl) {		lptmp = list_entry(tmp, struct ldm_part, part_list);		if (start > lptmp->start)			continue;		if (start < lptmp->start)			break;		printk(LDM_CRIT "Duplicate LDM partition entry! Skipping.\n");		kfree(lp);		return -1;	}	list_add_tail(&lp->part_list, tmp);	ldm_debug("Added LDM partition successfully.\n");	return 1;}/** * create_data_partitions - create the data partition devices * @hd:			gendisk structure in which to create the data partitions * @first_sector:	first sector within the disk device * @first_part_minor:	first minor number of data partition devices * @dev:		partition device holding the LDM database * @vm:			in memory vmdb structure of @dev * @ph:			in memory privhead structure of the disk device * @dk:			in memory ldmdisk structure of the disk device * * The database contains ALL the partitions for ALL the disks, so we need to * filter out this specific disk. Using the disk's object id, we can find all * the partitions in the database that belong to this disk. * * For each found partition, we create a corresponding partition device starting * with minor number @first_part_minor. But we do this in such a way that we * actually sort the partitions in order of on-disk position. Any invalid * partitions are completely ignored/skipped (an error is output but that's * all). * * Return 1 on success and -1 on error. */static int create_data_partitions(struct gendisk *hd,		const unsigned long first_sector, int first_part_minor,		struct block_device *bdev, const struct vmdb *vm,		const struct privhead *ph, const struct ldmdisk *dk,		unsigned long base){	Sector sect;	unsigned char *data;	struct vblk *vb;	LIST_HEAD(pl);		/* Sorted list of partitions. */	struct ldm_part *lp;	struct list_head *tmp;	int vblk;	int vsize;		/* VBLK size. */	int perbuf;		/* VBLKs per buffer. */	int buffer, lastbuf, lastofs, err, disk_minor;	vb = (struct vblk*)kmalloc(sizeof(struct vblk), GFP_KERNEL);	if (!vb)		goto no_mem;	vsize   = vm->vblk_size;	if (vsize < 1 || vsize > 512)		goto err_out;	perbuf  = 512 / vsize;	if (perbuf < 1 || 512 % vsize)		goto err_out;					/* 512 == VMDB size */	lastbuf = vm->last_vblk_seq / perbuf - 1;	lastofs = vm->last_vblk_seq % perbuf;	if (lastofs)		lastbuf++;	if (OFF_VBLK * LDM_BLOCKSIZE + vm->last_vblk_seq * vsize >			ph->config_size * 512)		goto err_out;	/*	 * Get the minor number of the parent device so we can check we don't	 * go beyond the end of the device.	 */	disk_minor = (first_part_minor >> hd->minor_shift) << hd->minor_shift;	for (buffer = 0; buffer < lastbuf; buffer++) {		data = read_dev_sector(bdev, base + 2*OFF_VBLK + buffer, &sect);		if (!data)			goto read_err;		for (vblk = 0; vblk < perbuf; vblk++) {			u8 *block;						if (lastofs && buffer == lastbuf - 1 && vblk >= lastofs)				break;			block = data + vsize * vblk;			if (block + vsize > data + 512)				goto brelse_out;			if (parse_vblk(block, vsize, vb) != 1)				continue;			if (vb->vblk_type != VBLK_PART)				continue;			if (dk->obj_id != vb->disk_id)				continue;			/* Ignore invalid partition errors. */			if (add_partition_to_list(&pl, hd, disk_minor,					first_sector + vb->start_sector +					ph->logical_disk_start,					vb->num_sectors) < -1)				goto brelse_out;		}		put_dev_sector(sect);	}	err = 1;out:	/* Finally create the nicely sorted data partitions. */	printk(" <");	list_for_each(tmp, &pl) {		lp = list_entry(tmp, struct ldm_part, part_list);		add_gd_partition(hd, first_part_minor++, lp->start, lp->size);	}	printk(" >\n");	if (!list_empty(&pl)) {		struct list_head *tmp2;		/* Cleanup the partition list which is now superfluous. */		list_for_each_safe(tmp, tmp2, &pl) {			lp = list_entry(tmp, struct ldm_part, part_list);			list_del(tmp);			kfree(lp);		}	}	kfree(vb);	return err;brelse_out:	put_dev_sector(sect);	goto err_out;no_mem:	printk(LDM_CRIT "Not enough memory to allocate required buffers.\n");	goto err_out;read_err:	printk(LDM_CRIT "Disk read failed in create_partitions.\n");err_out:	err = -1;	goto out;}/** * get_vnum - convert a variable-width, big endian number, to cpu u64 one * @block:	pointer to the variable-width number to convert * @err:	address of an integer into which to return the error code. * * This converts a variable-width, big endian number into a 64-bit, CPU format * number and returns the result with err set to 0. If an error occurs return 0 * with err set to -1. * * The first byte of a variable-width number is the size of the number in bytes. */static u64 get_vnum(const u8 *block, int *err){	u64 tmp = 0ULL;	u8 length = *block++;	if (length && length <= 8) {		while (length--)			tmp = (tmp << 8) | *block++;		*err = 0;	} else {		printk(LDM_ERR "Illegal length in get_vnum(): %d.\n", length);		*err = 1;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合在线视频| 国产成人免费在线视频| 精品制服美女丁香| av电影在线观看一区| 日韩欧美一区二区久久婷婷| |精品福利一区二区三区| 奇米四色…亚洲| 欧美日韩在线播放一区| 国产精品毛片无遮挡高清| 蜜桃精品视频在线| 欧美精品日韩一本| 一级精品视频在线观看宜春院 | 亚洲一区二区欧美| 国产99精品国产| 精品久久99ma| 捆绑紧缚一区二区三区视频| 欧美在线free| 亚洲综合激情另类小说区| 成人国产精品免费观看视频| 久久午夜老司机| 国产一区久久久| 精品精品国产高清a毛片牛牛| 青青青伊人色综合久久| 欧美一区日本一区韩国一区| 亚洲国产成人av好男人在线观看| 91在线视频18| 亚洲欧美另类久久久精品2019| 成人av资源下载| 国产精品热久久久久夜色精品三区| 韩国三级中文字幕hd久久精品| 精品乱码亚洲一区二区不卡| 免费成人小视频| 精品精品国产高清一毛片一天堂| 韩国一区二区视频| 国产亚洲一区字幕| 丁香五精品蜜臀久久久久99网站 | 国产在线麻豆精品观看| 日韩限制级电影在线观看| 美女视频黄 久久| 精品国产一区二区三区久久久蜜月 | 欧美视频三区在线播放| 亚洲一区二区三区爽爽爽爽爽| 欧美三级视频在线播放| 日本成人在线视频网站| 精品成人a区在线观看| 国产寡妇亲子伦一区二区| 国产精品狼人久久影院观看方式| 91女人视频在线观看| 亚洲国产精品久久久久婷婷884| 欧美日韩一级二级| 狠狠色综合播放一区二区| 中文字幕不卡的av| 欧美综合一区二区| 免费成人美女在线观看.| 久久久亚洲精品一区二区三区| 高清不卡在线观看| 亚洲国产va精品久久久不卡综合 | 美女免费视频一区| 国产精品伦一区二区三级视频| 在线观看欧美黄色| 久久91精品国产91久久小草 | 精品久久久久久久久久久久久久久久久 | 麻豆成人久久精品二区三区小说| 久久网这里都是精品| 色www精品视频在线观看| 日韩高清不卡在线| 欧美激情一区二区三区不卡| 欧美三级中文字| 精品写真视频在线观看| 中文字幕中文字幕在线一区| 在线播放中文一区| 成人性生交大片免费看视频在线| 一区二区三区国产| 精品国产乱码久久久久久1区2区| av在线不卡网| 精品亚洲porn| 日韩精品国产精品| 亚洲精品国产视频| 国产欧美日韩三区| 欧美一级理论片| 在线国产电影不卡| 成人国产视频在线观看| 日本亚洲电影天堂| 一级中文字幕一区二区| 国产性天天综合网| 日韩一区二区在线观看| 91激情五月电影| 国产99一区视频免费 | 亚洲最大成人网4388xx| 欧美国产一区二区| 欧美美女网站色| 色老综合老女人久久久| 从欧美一区二区三区| 激情综合网激情| 偷拍一区二区三区四区| 夜夜操天天操亚洲| 中文字幕中文字幕在线一区 | 欧美大度的电影原声| 色哟哟欧美精品| 99re热这里只有精品视频| 国产一区二区三区高清播放| 人禽交欧美网站| 日韩中文字幕麻豆| 亚洲午夜久久久久久久久久久| 亚洲视频狠狠干| 国产精品毛片久久久久久久| 国产网红主播福利一区二区| 2019国产精品| 久久夜色精品国产噜噜av| 久久综合狠狠综合久久综合88| 精品久久久久久久久久久久久久久 | 欧美中文字幕久久| 色婷婷综合久久久久中文一区二区| 福利电影一区二区三区| 国产高清一区日本| 成人精品视频一区| av激情成人网| 99国产精品久久久久久久久久| 91麻豆精东视频| 色综合咪咪久久| 欧美日韩一区二区三区不卡| 在线不卡一区二区| 精品区一区二区| 久久亚洲精精品中文字幕早川悠里| 亚洲精品一区二区三区在线观看 | 欧美一卡在线观看| 欧美精品一区二区三区蜜桃| 欧美精品一区二区在线播放| 国产日韩欧美精品综合| 自拍视频在线观看一区二区| 亚洲v精品v日韩v欧美v专区| 毛片av中文字幕一区二区| 国产福利91精品| 色综合久久天天| 日韩一区二区免费视频| 国产精品无码永久免费888| 亚洲欧美日韩中文播放| 午夜伊人狠狠久久| 国产乱码一区二区三区| 91蜜桃在线观看| 日韩亚洲欧美中文三级| 国产亚洲视频系列| 一区二区三区精品久久久| 日韩av电影免费观看高清完整版 | 欧美在线你懂的| 日韩欧美色综合| 一区在线观看免费| 日本不卡免费在线视频| k8久久久一区二区三区| 欧美日韩免费观看一区三区| 精品成人一区二区三区| 一区二区三区日韩精品视频| 乱一区二区av| 在线观看免费亚洲| 精品国产91乱码一区二区三区| 中文字幕一区二区三区蜜月 | 337p粉嫩大胆噜噜噜噜噜91av| 国产精品国产三级国产三级人妇| 天使萌一区二区三区免费观看| 久久99蜜桃精品| 欧美在线观看一区| 国产人久久人人人人爽| 午夜伦理一区二区| 成人免费观看av| 精品美女被调教视频大全网站| 亚洲精品成人在线| 国产a区久久久| 日韩美女一区二区三区四区| 一区二区久久久久| 欧美在线免费播放| 国产女人水真多18毛片18精品视频| 天天综合日日夜夜精品| 97精品超碰一区二区三区| 久久久三级国产网站| 日韩av网站免费在线| 欧美做爰猛烈大尺度电影无法无天| 欧美国产精品v| 久久www免费人成看片高清| 欧美男人的天堂一二区| 一区二区三区四区激情| 成人av电影在线| 国产视频一区二区在线| 久久99精品久久久久久动态图| 欧美日韩成人在线一区| 一区二区三区中文在线观看| 成人高清视频免费观看| 久久久精品天堂| 国产精品18久久久久久vr| 欧美tk丨vk视频| 激情图片小说一区| 精品播放一区二区| 国产毛片精品视频| 26uuu国产一区二区三区| 另类小说视频一区二区| 日韩欧美国产不卡| 韩国理伦片一区二区三区在线播放 | 欧美日韩成人综合| 午夜不卡av免费| 欧美日韩大陆在线| 亚洲一线二线三线视频|