/****************************************************************** * NAME: OpenFilSys * * FUNCTION: Read the superblock into a buffer. * Extract various pieces of information. * Release the buffer. * * PARAMETERS: none * * NOTES: * * RETURNS: * success: 0 * failure: something else */ int32 OpenFilSys( void ) { int32 rc; struct superblock *sb; buf_t *bp; /* * validate and retrieve fs parameters from superblock */ /* try to read the primary superblock */ rc = bRawRead(LVHandle, (int64)SUPER1_OFF, (int32)PAGESIZE, &bp); if (rc != 0) { /* try to read the secondary superblock */ rc = bRawRead(LVHandle, (int64)SUPER2_OFF, (int32)PAGESIZE, &bp); if (rc != 0) { #ifdef _JFS_DEBUG printf("OpenFilSys: i/o error: rc=%d\n", rc); #endif return CBBL_CANTREADSBLKS; } } sb = (struct superblock *)bp->b_data; /* check magic/version number */ if (strncmp(sb->s_magic,JFS_MAGIC,(unsigned)strlen(JFS_MAGIC)) || (sb->s_version != JFS_VERSION)) { return CBBL_INVALMAGORVERS; } if (sb->s_state & FM_DIRTY) { return CBBL_FSDIRTY; } fsMount->bsize = sb->s_bsize; fsMount->l2bsize = sb->s_l2bsize; fsMount->l2bfactor = sb->s_l2bfactor; fsMount->nbperpage = PAGESIZE >> fsMount->l2bsize; fsMount->l2nbperpage = log2shift(fsMount->nbperpage); fsMount->FSSize = sb->s_size >> sb->s_l2bfactor; fsMount->AGSize = sb->s_agsize; #ifdef _JFS_DEBUG printf("superblock: attribute:0x%08x state:0x%08x\n", sb->s_flag, sb->s_state); printf("superblock: bsize:%d FSSize:%lld\n", fsMount->bsize, fsMount->FSSize); #endif agg_recptr->fs_blksize = sb->s_bsize; /* aggregate block size */ agg_recptr->lv_blksize = sb->s_pbsize; /* device block size */ agg_recptr->fs_lv_ratio = sb->s_bsize / sb->s_pbsize; agg_recptr->fs_last_metablk = addressPXD( &sb->s_aim2 ) + lengthPXD( &sb->s_aim2); agg_recptr->fs_first_wspblk = addressPXD( &sb->s_fsckpxd ); bRelease(bp); return rc; } /* end OpenFilSys() */
/**************************************************************************** * NAME: process_BadBlockInode * * FUNCTION: Reads in the inode extent containing the JFS Bad Block * inode and calls process_Inode() to scan for blocks on the * bad block list and handle any that are detected. * * PARAMETERS: none * * NOTES: * * RETURNS: * success: 0 * failure: something else */ int32 process_BadBlockInode ( ) { int32 pbbi_rc = 0; dinode_t *bb_inoptr = NULL; int32 i; buf_t *bp; int8 isBadBlockInode = -1; /* * read in the aggregate bad block inode (i_number = BADBLOCK_I) */ i = BADBLOCK_I / INOSPERPAGE; pbbi_rc = bRawRead( LVHandle, (int64)(AITBL_OFF + PAGESIZE * i), PAGESIZE, &bp ); if( pbbi_rc ) { return( CBBL_CANTREADBBINO ); } /* * locate the inode in the buffer page */ bb_inoptr = (dinode_t *)bp->b_data; bb_inoptr += BADBLOCK_I & (INOSPERPAGE - 1); /* * check for list entries already assigned * to this inode */ pbbi_rc = process_Inode( isBadBlockInode, bb_inoptr ); return( pbbi_rc ); } /* end process_BadBlockInode() */
/****************************************************************** * NAME: preamble * * FUNCTION: Open the logical volume containing the file system. * Read aggregate-level control structures for the file * system inodes. * * PARAMETERS: none * * NOTES: * * RETURNS: * success: 0 * failure: something else */ int32 preamble( HFILE DevIo ) { int32 rc = 0; buf_t *bp; dinode_t *dip; int32 i; /* * validate and open LV */ if(!DevIo) //PS24072004 { rc = openLV(LVName); if ( rc != 0 ) return CBBL_CANTOPENLV; } else LVHandle=DevIo; //PS24072004 /* * Open FS */ rc = OpenFilSys(); if ( rc != 0 ) return rc; /* OpenFilSys assigns a unique CBBL return code */ /* * read in the fileset inode allocation map inode (i_number = 16) */ i = FILESYSTEM_I / INOSPERPAGE; rc = bRawRead(LVHandle, (int64)(AITBL_OFF + PAGESIZE * i), PAGESIZE, &bp); if ( rc != 0 ) { return CBBL_CANTREADIMAPINO; } /* * locate the inode in the buffer page */ dip = (dinode_t *)bp->b_data; dip += FILESYSTEM_I & (INOSPERPAGE - 1); memcpy(diIMap, dip, DISIZE); bRelease(bp); /* * read imap global control page */ rc = readIMapGCPSequential(iMap, &iagbuf); if ( rc != 0 ) return CBBL_CANTREADIMAPCTL; return rc; }