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

📄 inodes.c

📁 jfs 源码
💻 C
📖 第 1 页 / 共 2 页
字号:
	 * is for the stbl index not the slot index.	 */	root_header = (dtroot_t *) & (inode_buffer.di_DASD);	root_header->header.flag = DXD_INDEX | BT_ROOT | BT_LEAF;	setDASDLIMIT(&(root_header->header.DASD), 0);	setDASDUSED(&(root_header->header.DASD), 0);	root_header->header.nextindex = 0;	/*	 * Determine how many slots will fit	 */	root_header->header.freecnt = DTROOTMAXSLOT - 1;	root_header->header.freelist = DTENTRYSTART;	root_header->header.idotdot = 2;	for (index = DTENTRYSTART; index < DTROOTMAXSLOT; index++) {		root_header->slot[index].cnt = 1;		root_header->slot[index].next = index + 1;	}	/*	 * Last entry should end the free list.	 */	index--;	root_header->slot[index].next = -1;	memcpy(bp, &inode_buffer, sizeof (inode_buffer));	bp = (char *) bp + sizeof (inode_buffer);	/*	 * Inode 3 - ACL File	 */	memset(&inode_buffer, 0, sizeof (inode_buffer));	init_inode(&inode_buffer, FILESYSTEM_I, ACL_I, 0, 0, 0,		   IFJOURNAL | IFREG, no_data, fileset_start, aggr_block_size,		   inostamp);	memcpy(bp, &inode_buffer, sizeof (inode_buffer));	/*	 * Write Inode extent to disk	 */	/* swap if on big endian machine */	bp = buffer;	for (i = 0; i < 4; i++) {		ujfs_swap_dinode((struct dinode *) bp, PUT, type_jfs);		bp = (char *) bp + sizeof (inode_buffer);	}	rc = ujfs_rw_diskblocks(dev_ptr, *inode_location, *inode_size, buffer,				PUT);	free(buffer);	if (rc != 0)		return rc;	/*	 * Mark blocks allocated in block allocation map	 */	first_block = *inode_location / aggr_block_size;	last_block = (*inode_location + *inode_size) / aggr_block_size;	for (index = first_block; ((index < last_block) && (rc == 0)); index++) {		rc = markit(index, ALLOC);	}	return (rc);}/* * NAME: init_fileset_inodes * * FUNCTION: Initialize fileset inodes in aggregate inode table * * PARAMETERS: *      aggr_block_size - block size for aggregate *      dev_ptr         - open port for device to write to *      inode_map_loc   - byte offset for first extent of fileset's inode map *      inode_map_size  - byte count for first extent of fileset's inode map *      fileset_start   - First block of fileset. Will be used to determine *                        location of the AG table. *      inostamp        - time stamp for inodes in this fileset * * RETURNS: *      success: 0 *      failure: any other value */int init_fileset_inodes(int aggr_block_size,			HFILE dev_ptr,			int64_t inode_map_loc,			int inode_map_size,			int64_t fileset_start, 			unsigned inostamp){	struct dinode inode_buffer;	unsigned inode_num;	int rc;	/*	 * Figure out which is the next free aggregate fileset inode	 *	 * Release 1 only supports one fileset per aggregate, so we know this 	 * will always be inode FILESYSTEM_I in the aggregate inode table.  In 	 * future releases we will need to modify this code to look in the 	 * aggregate inode table for the next available free inode.	 */#ifdef ONE_FILESET_PER_AGGR	inode_num = FILESYSTEM_I;#else	inode_num = get_next_free();#endif				/* ONE_FILESET_PER_AGGR */	/*	 * Initialize Fileset Inode: Fileset Inode Allocation Map	 */	memset(&inode_buffer, 0, sizeof (inode_buffer));	init_inode(&inode_buffer, AGGREGATE_I, inode_num,		   inode_map_size / aggr_block_size, inode_map_size,		   inode_map_loc, IFJOURNAL | IFREG, max_extent_data,		   AITBL_OFF / aggr_block_size, aggr_block_size, inostamp);	/* swap here if necessary for big endian */	inode_buffer.di_gengen = __le32_to_cpu(1);	/*	 * Write fileset inode to disk	 */	rc = ujfs_rwinode(dev_ptr, &inode_buffer, inode_num, PUT,			  aggr_block_size, AGGREGATE_I, type_jfs);	return (rc);}/* * NAME: init_inode * * FUNCTION: Initialize inode fields for an inode with a single extent or inline *      data or a directory inode * * PARAMETERS: *      new_inode       - Pointer to inode to be initialized *      fileset_num     - Fileset number for inode *      inode_num       - Inode number of inode *      num_blocks      - Number of aggregate blocks allocated to inode *      size            - Size in bytes allocated to inode *      first_block     - Offset of first block of inode's extent *      mode            - Mode for inode *      inode_type      - Indicates the type of inode to be initialized. *                        Currently supported types are inline data, extents, *                        and no data.  The other parameters to this function *                        will provide the necessary information. *      inoext_address  - Address of inode extent containing this inode *      aggr_block_size - Aggregate block size *      inostamp        - Stamp used to identify inode as belonging to fileset * * RETURNS: None */void init_inode(struct dinode *new_inode,		int fileset_num,		unsigned inode_num,		int64_t num_blocks,		int64_t size,		int64_t first_block,		mode_t mode,		ino_data_type inode_type,		int64_t inoext_address, 		int aggr_block_size, 		unsigned inostamp){	/*	 * Initialize inode with where this stuff lives	 */	new_inode->di_inostamp = inostamp;	new_inode->di_fileset = fileset_num;	new_inode->di_number = inode_num;	new_inode->di_gen = 1;	PXDaddress(&(new_inode->di_ixpxd), inoext_address);	PXDlength(&(new_inode->di_ixpxd), INODE_EXTENT_SIZE / aggr_block_size);	new_inode->di_mode = mode;	new_inode->di_nblocks = num_blocks;	new_inode->di_size = size;	new_inode->di_nlink = 1;	new_inode->di_next_index = 2;	switch (inode_type) {	case inline_data:		new_inode->di_dxd.flag = DXD_INLINE;		DXDlength(&(new_inode->di_dxd),			  sizeof (struct dinode) - offsetof(struct dinode,							    di_inlinedata));		DXDaddress(&(new_inode->di_dxd), 0);		break;	case extent_data:	case max_extent_data:		((xtpage_t *) & (new_inode->di_DASD))->header.flag =		    DXD_INDEX | BT_ROOT | BT_LEAF;		/*		 * Since this is the root, we don't actually use the next and 		 * prev entries.  Set to 0 in case we decide to use this space 		 * for something in the future.		 */		((xtpage_t *) & (new_inode->di_DASD))->header.next = 0;		((xtpage_t *) & (new_inode->di_DASD))->header.prev = 0;		((xtpage_t *) & (new_inode->di_DASD))->header.nextindex =		    XTENTRYSTART + 1;		((xtpage_t *) & (new_inode->di_DASD))->header.maxentry =		    XTROOTMAXSLOT;		((xtpage_t *) & (new_inode->di_DASD))->xad[XTENTRYSTART].flag =		    0;		((xtpage_t *) & (new_inode->di_DASD))->xad[XTENTRYSTART].rsvrd =		    0;		XADoffset(&((xtpage_t *) & (new_inode->di_DASD))->			  xad[XTENTRYSTART], 0);		XADlength(&((xtpage_t *) & (new_inode->di_DASD))->			  xad[XTENTRYSTART], num_blocks);		XADaddress(&((xtpage_t *) & (new_inode->di_DASD))->			   xad[XTENTRYSTART], first_block);		break;	case no_data:		/*		 * No data to be filled in here, don't do anything		 */		((xtpage_t *) & (new_inode->di_DASD))->header.flag =		    DXD_INDEX | BT_ROOT | BT_LEAF;		/*		 * Since this is the root, we don't actually use the next and 		 * prev entries.  Set to 0 in case we decide to use this space 		 * for something in the future.		 */		((xtpage_t *) & (new_inode->di_DASD))->header.next = 0;		((xtpage_t *) & (new_inode->di_DASD))->header.prev = 0;		((xtpage_t *) & (new_inode->di_DASD))->header.nextindex =		    XTENTRYSTART;		((xtpage_t *) & (new_inode->di_DASD))->header.maxentry =		    XTROOTMAXSLOT;		((xtpage_t *) & (new_inode->di_DASD))->xad[XTENTRYSTART].flag =		    0;		((xtpage_t *) & (new_inode->di_DASD))->xad[XTENTRYSTART].rsvrd =		    0;		break;	default:		DBG_ERROR(("Internal error: %s(%d): Unrecognized inode data type %d\n", 			  __FILE__, __LINE__, inode_type))		    break;	}	new_inode->di_atime.tv_sec = new_inode->di_ctime.tv_sec =	    new_inode->di_mtime.tv_sec = new_inode->di_otime.tv_sec =	    (unsigned) time(NULL);	return;}

⌨️ 快捷键说明

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