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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? inode.c

?? LINUX1.0源代碼,代碼條理清晰
?? C
字號(hào):
/*
 *  linux/fs/inode.c
 *
 *  Copyright (C) 1991, 1992  Linus Torvalds
 */

#include <linux/stat.h>
#include <linux/sched.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/string.h>

#include <asm/system.h>

static struct inode_hash_entry {
	struct inode * inode;
	int updating;
} hash_table[NR_IHASH];

static struct inode * first_inode;
static struct wait_queue * inode_wait = NULL;
static int nr_inodes = 0, nr_free_inodes = 0;

static inline int const hashfn(dev_t dev, unsigned int i)
{
	return (dev ^ i) % NR_IHASH;
}

static inline struct inode_hash_entry * const hash(dev_t dev, int i)
{
	return hash_table + hashfn(dev, i);
}

static void insert_inode_free(struct inode *inode)
{
	inode->i_next = first_inode;
	inode->i_prev = first_inode->i_prev;
	inode->i_next->i_prev = inode;
	inode->i_prev->i_next = inode;
	first_inode = inode;
}

static void remove_inode_free(struct inode *inode)
{
	if (first_inode == inode)
		first_inode = first_inode->i_next;
	if (inode->i_next)
		inode->i_next->i_prev = inode->i_prev;
	if (inode->i_prev)
		inode->i_prev->i_next = inode->i_next;
	inode->i_next = inode->i_prev = NULL;
}

void insert_inode_hash(struct inode *inode)
{
	struct inode_hash_entry *h;
	h = hash(inode->i_dev, inode->i_ino);

	inode->i_hash_next = h->inode;
	inode->i_hash_prev = NULL;
	if (inode->i_hash_next)
		inode->i_hash_next->i_hash_prev = inode;
	h->inode = inode;
}

static void remove_inode_hash(struct inode *inode)
{
	struct inode_hash_entry *h;
	h = hash(inode->i_dev, inode->i_ino);

	if (h->inode == inode)
		h->inode = inode->i_hash_next;
	if (inode->i_hash_next)
		inode->i_hash_next->i_hash_prev = inode->i_hash_prev;
	if (inode->i_hash_prev)
		inode->i_hash_prev->i_hash_next = inode->i_hash_next;
	inode->i_hash_prev = inode->i_hash_next = NULL;
}

static void put_last_free(struct inode *inode)
{
	remove_inode_free(inode);
	inode->i_prev = first_inode->i_prev;
	inode->i_prev->i_next = inode;
	inode->i_next = first_inode;
	inode->i_next->i_prev = inode;
}

void grow_inodes(void)
{
	struct inode * inode;
	int i;

	if (!(inode = (struct inode*) get_free_page(GFP_KERNEL)))
		return;

	i=PAGE_SIZE / sizeof(struct inode);
	nr_inodes += i;
	nr_free_inodes += i;

	if (!first_inode)
		inode->i_next = inode->i_prev = first_inode = inode++, i--;

	for ( ; i ; i-- )
		insert_inode_free(inode++);
}

unsigned long inode_init(unsigned long start, unsigned long end)
{
	memset(hash_table, 0, sizeof(hash_table));
	first_inode = NULL;
	return start;
}

static void __wait_on_inode(struct inode *);

static inline void wait_on_inode(struct inode * inode)
{
	if (inode->i_lock)
		__wait_on_inode(inode);
}

static inline void lock_inode(struct inode * inode)
{
	wait_on_inode(inode);
	inode->i_lock = 1;
}

static inline void unlock_inode(struct inode * inode)
{
	inode->i_lock = 0;
	wake_up(&inode->i_wait);
}

/*
 * Note that we don't want to disturb any wait-queues when we discard
 * an inode.
 *
 * Argghh. Got bitten by a gcc problem with inlining: no way to tell
 * the compiler that the inline asm function 'memset' changes 'inode'.
 * I've been searching for the bug for days, and was getting desperate.
 * Finally looked at the assembler output... Grrr.
 *
 * The solution is the weird use of 'volatile'. Ho humm. Have to report
 * it to the gcc lists, and hope we can do this more cleanly some day..
 */
void clear_inode(struct inode * inode)
{
	struct wait_queue * wait;

	wait_on_inode(inode);
	remove_inode_hash(inode);
	remove_inode_free(inode);
	wait = ((volatile struct inode *) inode)->i_wait;
	if (inode->i_count)
		nr_free_inodes++;
	memset(inode,0,sizeof(*inode));
	((volatile struct inode *) inode)->i_wait = wait;
	insert_inode_free(inode);
}

int fs_may_mount(dev_t dev)
{
	struct inode * inode, * next;
	int i;

	next = first_inode;
	for (i = nr_inodes ; i > 0 ; i--) {
		inode = next;
		next = inode->i_next;	/* clear_inode() changes the queues.. */
		if (inode->i_dev != dev)
			continue;
		if (inode->i_count || inode->i_dirt || inode->i_lock)
			return 0;
		clear_inode(inode);
	}
	return 1;
}

int fs_may_umount(dev_t dev, struct inode * mount_root)
{
	struct inode * inode;
	int i;

	inode = first_inode;
	for (i=0 ; i < nr_inodes ; i++, inode = inode->i_next) {
		if (inode->i_dev != dev || !inode->i_count)
			continue;
		if (inode == mount_root && inode->i_count == 1)
			continue;
		return 0;
	}
	return 1;
}

int fs_may_remount_ro(dev_t dev)
{
	struct file * file;
	int i;

	/* Check that no files are currently opened for writing. */
	for (file = first_file, i=0; i<nr_files; i++, file=file->f_next) {
		if (!file->f_count || !file->f_inode ||
		    file->f_inode->i_dev != dev)
			continue;
		if (S_ISREG(file->f_inode->i_mode) && (file->f_mode & 2))
			return 0;
	}
	return 1;
}

static void write_inode(struct inode * inode)
{
	if (!inode->i_dirt)
		return;
	wait_on_inode(inode);
	if (!inode->i_dirt)
		return;
	if (!inode->i_sb || !inode->i_sb->s_op || !inode->i_sb->s_op->write_inode) {
		inode->i_dirt = 0;
		return;
	}
	inode->i_lock = 1;	
	inode->i_sb->s_op->write_inode(inode);
	unlock_inode(inode);
}

static void read_inode(struct inode * inode)
{
	lock_inode(inode);
	if (inode->i_sb && inode->i_sb->s_op && inode->i_sb->s_op->read_inode)
		inode->i_sb->s_op->read_inode(inode);
	unlock_inode(inode);
}

/*
 * notify_change is called for inode-changing operations such as
 * chown, chmod, utime, and truncate.  It is guaranteed (unlike
 * write_inode) to be called from the context of the user requesting
 * the change.  It is not called for ordinary access-time updates.
 * NFS uses this to get the authentication correct.  -- jrs
 */

int notify_change(int flags, struct inode * inode)
{
	if (inode->i_sb && inode->i_sb->s_op  &&
	    inode->i_sb->s_op->notify_change)
		return inode->i_sb->s_op->notify_change(flags, inode);
	return 0;
}

/*
 * bmap is needed for demand-loading and paging: if this function
 * doesn't exist for a filesystem, then those things are impossible:
 * executables cannot be run from the filesystem etc...
 *
 * This isn't as bad as it sounds: the read-routines might still work,
 * so the filesystem would be otherwise ok (for example, you might have
 * a DOS filesystem, which doesn't lend itself to bmap very well, but
 * you could still transfer files to/from the filesystem)
 */
int bmap(struct inode * inode, int block)
{
	if (inode->i_op && inode->i_op->bmap)
		return inode->i_op->bmap(inode,block);
	return 0;
}

void invalidate_inodes(dev_t dev)
{
	struct inode * inode, * next;
	int i;

	next = first_inode;
	for(i = nr_inodes ; i > 0 ; i--) {
		inode = next;
		next = inode->i_next;		/* clear_inode() changes the queues.. */
		if (inode->i_dev != dev)
			continue;
		if (inode->i_count || inode->i_dirt || inode->i_lock) {
			printk("VFS: inode busy on removed device %d/%d\n", MAJOR(dev), MINOR(dev));
			continue;
		}
		clear_inode(inode);
	}
}

void sync_inodes(dev_t dev)
{
	int i;
	struct inode * inode;

	inode = first_inode;
	for(i = 0; i < nr_inodes*2; i++, inode = inode->i_next) {
		if (dev && inode->i_dev != dev)
			continue;
		wait_on_inode(inode);
		if (inode->i_dirt)
			write_inode(inode);
	}
}

void iput(struct inode * inode)
{
	if (!inode)
		return;
	wait_on_inode(inode);
	if (!inode->i_count) {
		printk("VFS: iput: trying to free free inode\n");
		printk("VFS: device %d/%d, inode %lu, mode=0%07o\n",
			MAJOR(inode->i_rdev), MINOR(inode->i_rdev),
					inode->i_ino, inode->i_mode);
		return;
	}
	if (inode->i_pipe)
		wake_up_interruptible(&PIPE_WAIT(*inode));
repeat:
	if (inode->i_count>1) {
		inode->i_count--;
		return;
	}
	wake_up(&inode_wait);
	if (inode->i_pipe) {
		unsigned long page = (unsigned long) PIPE_BASE(*inode);
		PIPE_BASE(*inode) = NULL;
		free_page(page);
	}
	if (inode->i_sb && inode->i_sb->s_op && inode->i_sb->s_op->put_inode) {
		inode->i_sb->s_op->put_inode(inode);
		if (!inode->i_nlink)
			return;
	}
	if (inode->i_dirt) {
		write_inode(inode);	/* we can sleep - so do again */
		wait_on_inode(inode);
		goto repeat;
	}
	inode->i_count--;
	nr_free_inodes++;
	return;
}

struct inode * get_empty_inode(void)
{
	struct inode * inode, * best;
	int i;

	if (nr_inodes < NR_INODE && nr_free_inodes < (nr_inodes >> 2))
		grow_inodes();
repeat:
	inode = first_inode;
	best = NULL;
	for (i = 0; i<nr_inodes; inode = inode->i_next, i++) {
		if (!inode->i_count) {
			if (!best)
				best = inode;
			if (!inode->i_dirt && !inode->i_lock) {
				best = inode;
				break;
			}
		}
	}
	if (!best || best->i_dirt || best->i_lock)
		if (nr_inodes < NR_INODE) {
			grow_inodes();
			goto repeat;
		}
	inode = best;
	if (!inode) {
		printk("VFS: No free inodes - contact Linus\n");
		sleep_on(&inode_wait);
		goto repeat;
	}
	if (inode->i_lock) {
		wait_on_inode(inode);
		goto repeat;
	}
	if (inode->i_dirt) {
		write_inode(inode);
		goto repeat;
	}
	if (inode->i_count)
		goto repeat;
	clear_inode(inode);
	inode->i_count = 1;
	inode->i_nlink = 1;
	inode->i_sem.count = 1;
	nr_free_inodes--;
	if (nr_free_inodes < 0) {
		printk ("VFS: get_empty_inode: bad free inode count.\n");
		nr_free_inodes = 0;
	}
	return inode;
}

struct inode * get_pipe_inode(void)
{
	struct inode * inode;
	extern struct inode_operations pipe_inode_operations;

	if (!(inode = get_empty_inode()))
		return NULL;
	if (!(PIPE_BASE(*inode) = (char*) __get_free_page(GFP_USER))) {
		iput(inode);
		return NULL;
	}
	inode->i_op = &pipe_inode_operations;
	inode->i_count = 2;	/* sum of readers/writers */
	PIPE_WAIT(*inode) = NULL;
	PIPE_START(*inode) = PIPE_LEN(*inode) = 0;
	PIPE_RD_OPENERS(*inode) = PIPE_WR_OPENERS(*inode) = 0;
	PIPE_READERS(*inode) = PIPE_WRITERS(*inode) = 1;
	PIPE_LOCK(*inode) = 0;
	inode->i_pipe = 1;
	inode->i_mode |= S_IFIFO | S_IRUSR | S_IWUSR;
	inode->i_uid = current->euid;
	inode->i_gid = current->egid;
	inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
	return inode;
}

struct inode * iget(struct super_block * sb,int nr)
{
	return __iget(sb,nr,1);
}

struct inode * __iget(struct super_block * sb, int nr, int crossmntp)
{
	static struct wait_queue * update_wait = NULL;
	struct inode_hash_entry * h;
	struct inode * inode;
	struct inode * empty = NULL;

	if (!sb)
		panic("VFS: iget with sb==NULL");
	h = hash(sb->s_dev, nr);
repeat:
	for (inode = h->inode; inode ; inode = inode->i_hash_next)
		if (inode->i_dev == sb->s_dev && inode->i_ino == nr)
			goto found_it;
	if (!empty) {
		h->updating++;
		empty = get_empty_inode();
		if (!--h->updating)
			wake_up(&update_wait);
		if (empty)
			goto repeat;
		return (NULL);
	}
	inode = empty;
	inode->i_sb = sb;
	inode->i_dev = sb->s_dev;
	inode->i_ino = nr;
	inode->i_flags = sb->s_flags;
	put_last_free(inode);
	insert_inode_hash(inode);
	read_inode(inode);
	goto return_it;

found_it:
	if (!inode->i_count)
		nr_free_inodes--;
	inode->i_count++;
	wait_on_inode(inode);
	if (inode->i_dev != sb->s_dev || inode->i_ino != nr) {
		printk("Whee.. inode changed from under us. Tell Linus\n");
		iput(inode);
		goto repeat;
	}
	if (crossmntp && inode->i_mount) {
		struct inode * tmp = inode->i_mount;
		tmp->i_count++;
		iput(inode);
		inode = tmp;
		wait_on_inode(inode);
	}
	if (empty)
		iput(empty);

return_it:
	while (h->updating)
		sleep_on(&update_wait);
	return inode;
}

/*
 * The "new" scheduling primitives (new as of 0.97 or so) allow this to
 * be done without disabling interrupts (other than in the actual queue
 * updating things: only a couple of 386 instructions). This should be
 * much better for interrupt latency.
 */
static void __wait_on_inode(struct inode * inode)
{
	struct wait_queue wait = { current, NULL };

	add_wait_queue(&inode->i_wait, &wait);
repeat:
	current->state = TASK_UNINTERRUPTIBLE;
	if (inode->i_lock) {
		schedule();
		goto repeat;
	}
	remove_wait_queue(&inode->i_wait, &wait);
	current->state = TASK_RUNNING;
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一区二区久激情瑜伽| 国产精品一区二区三区99| 精品国产一区二区亚洲人成毛片| 成人免费av资源| 青青草国产精品亚洲专区无| 综合在线观看色| 日韩精品一区二区三区蜜臀 | 在线国产电影不卡| 国产曰批免费观看久久久| 亚洲国产cao| 亚洲男同性视频| 日本一区二区免费在线观看视频 | 日韩欧美aaaaaa| 色噜噜夜夜夜综合网| 国产福利精品一区二区| 视频一区免费在线观看| 亚洲一区二区三区视频在线| 中文一区二区完整视频在线观看| 日韩欧美的一区二区| 欧美精品九九99久久| 一本到三区不卡视频| 成人激情综合网站| 国产一区999| 日韩不卡免费视频| 五月天激情综合| 亚洲国产精品久久人人爱| 亚洲精品国产精品乱码不99| 亚洲色欲色欲www| 国产肉丝袜一区二区| 久久精品一区四区| 久久免费美女视频| 日韩精品一区二区三区视频播放 | 国产一区91精品张津瑜| 免费高清视频精品| 日韩精品成人一区二区三区| 亚洲成av人影院| 亚洲国产精品嫩草影院| 午夜激情一区二区三区| 丝袜国产日韩另类美女| 日韩电影在线观看电影| 日本午夜一本久久久综合| 青青国产91久久久久久| 久久国产日韩欧美精品| 国内成人免费视频| 国产乱人伦偷精品视频免下载| 国产精品一区二区男女羞羞无遮挡 | 91麻豆精品国产91久久久更新时间 | 精品在线观看免费| 国产一区二区在线电影| 国产黑丝在线一区二区三区| 国产盗摄一区二区三区| 国产河南妇女毛片精品久久久| 国产91丝袜在线播放| 成人精品国产一区二区4080| 91免费视频大全| 欧美综合视频在线观看| 4438亚洲最大| 久久中文字幕电影| 国产精品污污网站在线观看| 一区二区三区四区五区视频在线观看| 亚洲人成在线播放网站岛国| 亚洲图片欧美色图| 蜜臀91精品一区二区三区| 国产91丝袜在线播放0| 色综合久久综合网97色综合| 欧美人xxxx| 欧美精品一区二区不卡 | 国产三级精品三级| 亚洲美女在线国产| 日本不卡123| 成人免费的视频| 欧美日韩免费不卡视频一区二区三区| 欧美一区二区播放| 国产精品午夜在线观看| 亚洲1区2区3区视频| 九九精品一区二区| 色综合一区二区| 日韩精品一区国产麻豆| 中文字幕亚洲欧美在线不卡| 图片区小说区国产精品视频| 国产成人精品1024| 欧美精品成人一区二区三区四区| wwwwww.欧美系列| 1024国产精品| 美女一区二区在线观看| 91视频在线观看免费| 3d动漫精品啪啪| 亚洲色欲色欲www| 狠狠久久亚洲欧美| 欧美日韩一区不卡| 国产精品久久久久影视| 另类人妖一区二区av| 色综合久久久久综合体桃花网| 日韩欧美一区二区在线视频| 中文字幕综合网| 久久激情五月婷婷| 欧美日免费三级在线| 国产精品色婷婷| 蜜桃传媒麻豆第一区在线观看| 色综合天天综合网天天狠天天| 2019国产精品| 日日欢夜夜爽一区| 在线观看成人免费视频| 国产精品视频看| 久久电影网站中文字幕 | 中文字幕中文乱码欧美一区二区| 免费观看成人鲁鲁鲁鲁鲁视频| 91成人网在线| 中文字幕精品综合| 狠狠色狠狠色综合| 91精品在线观看入口| 亚洲婷婷综合久久一本伊一区| 国产一区二区三区免费观看| 91精品在线麻豆| 亚洲高清中文字幕| 91黄色小视频| 亚洲免费伊人电影| 99久久精品国产毛片| 中文字幕av在线一区二区三区| 精品一区二区av| 日韩你懂的在线观看| 日本不卡一区二区三区| 欧美精品vⅰdeose4hd| 亚洲一级二级三级在线免费观看| 91丨porny丨户外露出| 亚洲欧洲精品天堂一级| av午夜精品一区二区三区| 国产精品久久久久久久第一福利| 国产精品一二三四| 国产午夜精品美女毛片视频| 国产精品一二二区| 欧美精品一区二区在线观看| 久久国产婷婷国产香蕉| 精品99久久久久久| 激情综合色丁香一区二区| 精品成a人在线观看| 国产乱码精品一品二品| 国产亚洲欧美一区在线观看| 国产精品一区专区| 中文字幕欧美激情| 91麻豆免费看| 一区二区三区在线观看视频| 欧美亚洲禁片免费| 五月天网站亚洲| 欧美v国产在线一区二区三区| 久久国产乱子精品免费女| 久久综合九色欧美综合狠狠| 国产成人在线视频网址| 中文幕一区二区三区久久蜜桃| 99久久综合狠狠综合久久| 亚洲香肠在线观看| 日韩一区二区三区三四区视频在线观看| 麻豆一区二区99久久久久| 久久久久久久综合狠狠综合| 波多野结衣亚洲一区| 一区二区三区在线观看欧美| 8v天堂国产在线一区二区| 国产在线精品一区二区三区不卡| 久久精品一二三| av一区二区三区四区| 五月天中文字幕一区二区| 精品国产一区二区三区不卡 | 欧美一区二区精美| 国产麻豆精品视频| 亚洲男人的天堂在线aⅴ视频| 9191国产精品| 激情五月婷婷综合网| 亚洲美女淫视频| 91精品国产高清一区二区三区| 国产一区二区三区电影在线观看| 亚洲欧洲av在线| 欧美日韩成人综合在线一区二区| 国内精品国产三级国产a久久| 亚洲另类色综合网站| 欧美大片一区二区三区| 91女厕偷拍女厕偷拍高清| 日本欧美一区二区在线观看| 国产精品久久久久久久久久免费看| 欧美日本不卡视频| 国产99久久久国产精品潘金网站| 亚洲二区在线视频| 国产无一区二区| 欧美人与z0zoxxxx视频| 成人精品视频一区| 水野朝阳av一区二区三区| 久久久久久9999| 欧美日韩激情在线| 成人免费av在线| 精品一区二区三区的国产在线播放| 日韩美女视频一区二区| 精品久久久久久久久久久久包黑料| 色婷婷精品久久二区二区蜜臀av| 国产一区高清在线| 午夜成人免费电影| 日韩美女视频一区二区 | 日韩一级黄色大片| 一本久久精品一区二区| 国产黄人亚洲片| 久久精品国内一区二区三区| 亚洲线精品一区二区三区|