⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 util.h

📁 UnixBSD、SunOs、FreeBSD、NetBSD、OpenBSD和NeXTStep文件系统源代码
💻 H
📖 第 1 页 / 共 2 页
字号:
/* *  linux/fs/ufs/util.h * * Copyright (C) 1998  * Daniel Pirkl <daniel.pirkl@email.cz> * Charles University, Faculty of Mathematics and Physics */#include <linux/buffer_head.h>#include <linux/fs.h>#include "swab.h"/* * some useful macros */#define in_range(b,first,len)	((b)>=(first)&&(b)<(first)+(len))/* * functions used for retyping */static inline struct ufs_buffer_head *UCPI_UBH(struct ufs_cg_private_info *cpi){	return &cpi->c_ubh;}static inline struct ufs_buffer_head *USPI_UBH(struct ufs_sb_private_info *spi){	return &spi->s_ubh;}/* * macros used for accessing structures */static inline s32ufs_get_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1,		 struct ufs_super_block_third *usb3){	switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {	case UFS_ST_SUNOS:		if (fs32_to_cpu(sb, usb3->fs_postblformat) == UFS_42POSTBLFMT)			return fs32_to_cpu(sb, usb1->fs_u0.fs_sun.fs_state);		/* Fall Through to UFS_ST_SUN */	case UFS_ST_SUN:		return fs32_to_cpu(sb, usb3->fs_un2.fs_sun.fs_state);	case UFS_ST_SUNx86:		return fs32_to_cpu(sb, usb1->fs_u1.fs_sunx86.fs_state);	case UFS_ST_44BSD:	default:		return fs32_to_cpu(sb, usb3->fs_un2.fs_44.fs_state);	}}static inline voidufs_set_fs_state(struct super_block *sb, struct ufs_super_block_first *usb1,		 struct ufs_super_block_third *usb3, s32 value){	switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {	case UFS_ST_SUNOS:		if (fs32_to_cpu(sb, usb3->fs_postblformat) == UFS_42POSTBLFMT) {			usb1->fs_u0.fs_sun.fs_state = cpu_to_fs32(sb, value);			break;		}		/* Fall Through to UFS_ST_SUN */	case UFS_ST_SUN:		usb3->fs_un2.fs_sun.fs_state = cpu_to_fs32(sb, value);		break;	case UFS_ST_SUNx86:		usb1->fs_u1.fs_sunx86.fs_state = cpu_to_fs32(sb, value);		break;	case UFS_ST_44BSD:		usb3->fs_un2.fs_44.fs_state = cpu_to_fs32(sb, value);		break;	}}static inline u32ufs_get_fs_npsect(struct super_block *sb, struct ufs_super_block_first *usb1,		  struct ufs_super_block_third *usb3){	if ((UFS_SB(sb)->s_flags & UFS_ST_MASK) == UFS_ST_SUNx86)		return fs32_to_cpu(sb, usb3->fs_un2.fs_sunx86.fs_npsect);	else		return fs32_to_cpu(sb, usb1->fs_u1.fs_sun.fs_npsect);}static inline u64ufs_get_fs_qbmask(struct super_block *sb, struct ufs_super_block_third *usb3){	__fs64 tmp;	switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {	case UFS_ST_SUNOS:	case UFS_ST_SUN:		((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qbmask[0];		((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qbmask[1];		break;	case UFS_ST_SUNx86:		((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qbmask[0];		((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qbmask[1];		break;	case UFS_ST_44BSD:		((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qbmask[0];		((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qbmask[1];		break;	}	return fs64_to_cpu(sb, tmp);}static inline u64ufs_get_fs_qfmask(struct super_block *sb, struct ufs_super_block_third *usb3){	__fs64 tmp;	switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {	case UFS_ST_SUNOS:	case UFS_ST_SUN:		((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sun.fs_qfmask[0];		((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sun.fs_qfmask[1];		break;	case UFS_ST_SUNx86:		((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_sunx86.fs_qfmask[0];		((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_sunx86.fs_qfmask[1];		break;	case UFS_ST_44BSD:		((__fs32 *)&tmp)[0] = usb3->fs_un2.fs_44.fs_qfmask[0];		((__fs32 *)&tmp)[1] = usb3->fs_un2.fs_44.fs_qfmask[1];		break;	}	return fs64_to_cpu(sb, tmp);}static inline u16ufs_get_de_namlen(struct super_block *sb, struct ufs_dir_entry *de){	if ((UFS_SB(sb)->s_flags & UFS_DE_MASK) == UFS_DE_OLD)		return fs16_to_cpu(sb, de->d_u.d_namlen);	else		return de->d_u.d_44.d_namlen; /* XXX this seems wrong */}static inline voidufs_set_de_namlen(struct super_block *sb, struct ufs_dir_entry *de, u16 value){	if ((UFS_SB(sb)->s_flags & UFS_DE_MASK) == UFS_DE_OLD)		de->d_u.d_namlen = cpu_to_fs16(sb, value);	else		de->d_u.d_44.d_namlen = value; /* XXX this seems wrong */}static inline voidufs_set_de_type(struct super_block *sb, struct ufs_dir_entry *de, int mode){	if ((UFS_SB(sb)->s_flags & UFS_DE_MASK) != UFS_DE_44BSD)		return;	/*	 * TODO turn this into a table lookup	 */	switch (mode & S_IFMT) {	case S_IFSOCK:		de->d_u.d_44.d_type = DT_SOCK;		break;	case S_IFLNK:		de->d_u.d_44.d_type = DT_LNK;		break;	case S_IFREG:		de->d_u.d_44.d_type = DT_REG;		break;	case S_IFBLK:		de->d_u.d_44.d_type = DT_BLK;		break;	case S_IFDIR:		de->d_u.d_44.d_type = DT_DIR;		break;	case S_IFCHR:		de->d_u.d_44.d_type = DT_CHR;		break;	case S_IFIFO:		de->d_u.d_44.d_type = DT_FIFO;		break;	default:		de->d_u.d_44.d_type = DT_UNKNOWN;	}}static inline u32ufs_get_inode_uid(struct super_block *sb, struct ufs_inode *inode){	switch (UFS_SB(sb)->s_flags & UFS_UID_MASK) {	case UFS_UID_44BSD:		return fs32_to_cpu(sb, inode->ui_u3.ui_44.ui_uid);	case UFS_UID_EFT:		if (inode->ui_u1.oldids.ui_suid == 0xFFFF)			return fs32_to_cpu(sb, inode->ui_u3.ui_sun.ui_uid);		/* Fall through */	default:		return fs16_to_cpu(sb, inode->ui_u1.oldids.ui_suid);	}}static inline voidufs_set_inode_uid(struct super_block *sb, struct ufs_inode *inode, u32 value){	switch (UFS_SB(sb)->s_flags & UFS_UID_MASK) {	case UFS_UID_44BSD:		inode->ui_u3.ui_44.ui_uid = cpu_to_fs32(sb, value);		inode->ui_u1.oldids.ui_suid = cpu_to_fs16(sb, value);		break;	case UFS_UID_EFT:		inode->ui_u3.ui_sun.ui_uid = cpu_to_fs32(sb, value);		if (value > 0xFFFF)			value = 0xFFFF;		/* Fall through */	default:		inode->ui_u1.oldids.ui_suid = cpu_to_fs16(sb, value);		break;	}}static inline u32ufs_get_inode_gid(struct super_block *sb, struct ufs_inode *inode){	switch (UFS_SB(sb)->s_flags & UFS_UID_MASK) {	case UFS_UID_44BSD:		return fs32_to_cpu(sb, inode->ui_u3.ui_44.ui_gid);	case UFS_UID_EFT:		if (inode->ui_u1.oldids.ui_suid == 0xFFFF)			return fs32_to_cpu(sb, inode->ui_u3.ui_sun.ui_gid);		/* Fall through */	default:		return fs16_to_cpu(sb, inode->ui_u1.oldids.ui_sgid);	}}static inline voidufs_set_inode_gid(struct super_block *sb, struct ufs_inode *inode, u32 value){	switch (UFS_SB(sb)->s_flags & UFS_UID_MASK) {	case UFS_UID_44BSD:		inode->ui_u3.ui_44.ui_gid = cpu_to_fs32(sb, value);		inode->ui_u1.oldids.ui_sgid =  cpu_to_fs16(sb, value);		break;	case UFS_UID_EFT:		inode->ui_u3.ui_sun.ui_gid = cpu_to_fs32(sb, value);		if (value > 0xFFFF)			value = 0xFFFF;		/* Fall through */	default:		inode->ui_u1.oldids.ui_sgid =  cpu_to_fs16(sb, value);		break;	}}extern dev_t ufs_get_inode_dev(struct super_block *, struct ufs_inode_info *);extern void ufs_set_inode_dev(struct super_block *, struct ufs_inode_info *, dev_t);extern int __ufs_write_begin(struct file *file, struct address_space *mapping,		loff_t pos, unsigned len, unsigned flags,		struct page **pagep, void **fsdata);/* * These functions manipulate ufs buffers */#define ubh_bread(sb,fragment,size) _ubh_bread_(uspi,sb,fragment,size)  extern struct ufs_buffer_head * _ubh_bread_(struct ufs_sb_private_info *, struct super_block *, u64 , u64);extern struct ufs_buffer_head * ubh_bread_uspi(struct ufs_sb_private_info *, struct super_block *, u64, u64);extern void ubh_brelse (struct ufs_buffer_head *);extern void ubh_brelse_uspi (struct ufs_sb_private_info *);extern void ubh_mark_buffer_dirty (struct ufs_buffer_head *);extern void ubh_mark_buffer_uptodate (struct ufs_buffer_head *, int);extern void ubh_ll_rw_block(int, struct ufs_buffer_head *);extern void ubh_wait_on_buffer (struct ufs_buffer_head *);extern void ubh_bforget (struct ufs_buffer_head *);extern int  ubh_buffer_dirty (struct ufs_buffer_head *);#define ubh_ubhcpymem(mem,ubh,size) _ubh_ubhcpymem_(uspi,mem,ubh,size)extern void _ubh_ubhcpymem_(struct ufs_sb_private_info *, unsigned char *, struct ufs_buffer_head *, unsigned);#define ubh_memcpyubh(ubh,mem,size) _ubh_memcpyubh_(uspi,ubh,mem,size)extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head *, unsigned char *, unsigned);/* This functions works with cache pages*/extern struct page *ufs_get_locked_page(struct address_space *mapping,					pgoff_t index);static inline void ufs_put_locked_page(struct page *page){       unlock_page(page);       page_cache_release(page);}/* * macros and inline function to get important structures from ufs_sb_private_info */static inline void *get_usb_offset(struct ufs_sb_private_info *uspi,				   unsigned int offset)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -