struct inode * coda_iget(struct super_block * sb, ViceFid * fid, struct coda_vattr * attr) { struct inode *inode; struct coda_inode_info *cii; ino_t ino = coda_f2i(fid); inode = iget4(sb, ino, coda_inocmp, fid); if ( !inode ) { CDEBUG(D_CNODE, "coda_iget: no inode\n"); return ERR_PTR(-ENOMEM); } /* check if the inode is already initialized */ cii = ITOC(inode); if (coda_isnullfid(&cii->c_fid)) /* new, empty inode found... initializing */ cii->c_fid = *fid; /* we shouldnt see inode collisions anymore */ if (!coda_fideq(fid, &cii->c_fid)) BUG(); /* always replace the attributes, type might have changed */ coda_fill_inode(inode, attr); return inode; }
struct inode *fuse_iget(struct super_block *sb, unsigned long nodeid, int generation, struct fuse_attr *attr) { struct inode *inode; struct fuse_inode *fi; int retried = 0; retry: inode = iget4(sb, attr->ino, fuse_inode_eq, &nodeid); if (!inode) return NULL; if (!inode->u.generic_ip) { get_fuse_inode(inode)->nodeid = nodeid; inode->u.generic_ip = inode; inode->i_generation = generation; fuse_init_inode(inode, attr); } else if ((inode->i_mode ^ attr->mode) & S_IFMT) { BUG_ON(retried); /* Inode has changed type, any I/O on the old should fail */ remove_inode_hash(inode); make_bad_inode(inode); iput(inode); retried = 1; goto retry; } fi = get_fuse_inode(inode); fi->nlookup ++; fuse_change_attributes(inode, attr); return inode; }
/* convert a fid to an inode. */ struct inode *coda_fid_to_inode(ViceFid *fid, struct super_block *sb) { ino_t nr; struct inode *inode; struct coda_inode_info *cii; if ( !sb ) { printk("coda_fid_to_inode: no sb!\n"); return NULL; } CDEBUG(D_INODE, "%s\n", coda_f2s(fid)); nr = coda_f2i(fid); inode = iget4(sb, nr, coda_inocmp, fid); if ( !inode ) { printk("coda_fid_to_inode: null from iget, sb %p, nr %ld.\n", sb, (long)nr); return NULL; } cii = ITOC(inode); /* The inode could already be purged due to memory pressure */ if (coda_isnullfid(&cii->c_fid)) { inode->i_nlink = 0; iput(inode); return NULL; } /* we shouldn't see inode collisions anymore */ if ( !coda_fideq(fid, &cii->c_fid) ) BUG(); CDEBUG(D_INODE, "found %ld\n", inode->i_ino); return inode; }
void PrintByteCode( ClassFile *cf, uint8_t *code, int len ) { int ix = 0; while(ix < len) { int opcodeAddr = ix; uint8_t op = code[ix++]; char *opname = OPCodeFormat[op].name; char *fmt = OPCodeFormat[op].opnds_format; printf(" %3d: %s", opcodeAddr, opname); if (fmt != NULL) { int opndCnt = 0; int dest, low, high, npairs; int cpref = 0; char *cptype = NULL; while(*fmt != '\0') { char f = *fmt++; if (f != '0') { if (opndCnt++ > 0) putchar(','); putchar(' '); } switch(f) { case 'v': /* one byte index to a local variable */ printf(" %d", code[ix++]); break; case 'T': /* type (class/array/interface) ref, as a two byte index into the constant pool */ cpref = uget2(code,ix); cptype = "Type"; printf(" #%d", cpref); ix += 2; break; case 'C': /* class ref, as a two byte index into the constant pool */ cpref = uget2(code,ix); cptype = "Class"; printf(" #%d", cpref); ix += 2; break; case 'u': /* one byte unsigned immediate integer */ printf(" %d", code[ix]); ix++; break; case 's': /* one byte signed immediate integer */ printf(" %d", (signed char)code[ix]); ix++; break; case 'F': /* field ref, as a two byte index into the constant pool */ cpref = uget2(code,ix); cptype = "Field"; printf(" #%d", cpref); ix += 2; break; case 'I': /* interface ref, as a two byte index into the constant pool */ cpref = uget2(code,ix); cptype = "Interface"; printf(" #%d", cpref); ix += 2; break; case 'b': /* two byte branch destination */ dest = opcodeAddr + iget2(code,ix); printf(" %d", dest); ix += 2; break; case 'B': /* four byte branch destination */ printf(" %d", (int)(opcodeAddr + iget4(code,ix))); ix += 4; break; case 'M': /* method ref, as a two byte index into the constant pool */ cpref = uget2(code,ix); cptype = "Method"; printf(" #%d", cpref); ix += 2; break; case 'k': /* simple constant in constant pool, one byte index */ cpref = code[ix]; cptype = " "; printf(" #%d", cpref); ix++; break; case 'K': /* simple constant in constant pool, two byte index */ cpref = uget2(code,ix); cptype = " "; printf(" #%d", cpref); ix += 2; break; case 'a': /* one byte primitive type */ dest = code[ix] & 0xff; if (dest >= 12) dest = 0; printf(" %s", basicType[dest]); ix++; break; case 'S': /* two byte signed immediate integer */ printf(" %d", iget2(code,ix)); ix += 2; break; case '*': /* lookupswitch */ ix = (ix + 3) & 0xFFFFFFFC; /* skip over padding bytes */ printf("\n default: %d\n", (int)(opcodeAddr + iget4(code,ix))); ix += 4; npairs = iget4(code,ix); ix += 4; while(npairs-- > 0) { printf(" case %d:", iget4(code,ix)); ix += 4; printf(" %d\n", opcodeAddr + iget4(code,ix)); ix += 4; } break; case '&': /* tableswitch */ ix = (ix + 3) & 0xFFFFFFFC; /* skip over padding bytes */ printf("\n default: %d\n", opcodeAddr + iget4(code,ix)); ix += 4; low = iget4(code,ix); ix += 4; high = iget4(code,ix); ix += 4; while(low <= high) { printf(" case %d:", low++); printf(" %d\n", opcodeAddr + iget4(code,ix)); ix += 4; } break; case 'w': /* wide */ op = code[ix++]; /* the op being modified by wide */ printf("-%s %d", OPCodeFormat[op].name, uget2(code,ix)); ix += 2; if (op == 0x84) { /* iinc -- Format 2 */ printf(", %d", iget2(code,ix)); ix += 2; } break; case '0': /* a zero byte */ ix++; break; default: fprintf(stderr, "bad operand format code; op=%s, code=%c\n", opname, fmt[-1]); printf(" ???\n"); return; } } if (cptype != NULL) printf("; //%s %s", cptype, GetCPItemAsString(cf, cpref)); } putchar('\n'); } }
// // a portion of this function, particularly the VFS interface portion, // was derived from minix or ext2's analog and evolved as the // prototype did. You should be able to tell which portion by looking // at the ext2 code and comparing. It's subfunctions contain no code // used as a template unless they are so labeled. // static struct super_block * reiserfs_read_super (struct super_block * s, void * data, int silent) { int size; struct inode *root_inode; kdev_t dev = s->s_dev; int j; extern int *blksize_size[]; struct reiserfs_transaction_handle th ; int old_format = 0; unsigned long blocks; int jinit_done = 0 ; struct reiserfs_iget4_args args ; int old_magic; struct reiserfs_super_block * rs; memset (&s->u.reiserfs_sb, 0, sizeof (struct reiserfs_sb_info)); if (parse_options ((char *) data, &(s->u.reiserfs_sb.s_mount_opt), &blocks) == 0) { return NULL; } if (blocks) { printk("reserfs: resize option for remount only\n"); return NULL; } if (blksize_size[MAJOR(dev)] && blksize_size[MAJOR(dev)][MINOR(dev)] != 0) { /* as blocksize is set for partition we use it */ size = blksize_size[MAJOR(dev)][MINOR(dev)]; } else { size = BLOCK_SIZE; set_blocksize (s->s_dev, BLOCK_SIZE); } /* read block (64-th 1k block), which can contain reiserfs super block */ if (read_super_block (s, size, REISERFS_DISK_OFFSET_IN_BYTES)) { // try old format (undistributed bitmap, super block in 8-th 1k block of a device) if (read_super_block (s, size, REISERFS_OLD_DISK_OFFSET_IN_BYTES)) goto error; else old_format = 1; } rs = SB_DISK_SUPER_BLOCK (s); s->u.reiserfs_sb.s_mount_state = SB_REISERFS_STATE(s); s->u.reiserfs_sb.s_mount_state = REISERFS_VALID_FS ; if (old_format ? read_old_bitmaps(s) : read_bitmaps(s)) { printk ("reiserfs_read_super: unable to read bitmap\n"); goto error; } #ifdef CONFIG_REISERFS_CHECK printk("reiserfs:warning: CONFIG_REISERFS_CHECK is set ON\n"); printk("reiserfs:warning: - it is slow mode for debugging.\n"); #endif // set_device_ro(s->s_dev, 1) ; if (journal_init(s)) { printk("reiserfs_read_super: unable to initialize journal space\n") ; goto error ; } else { jinit_done = 1 ; /* once this is set, journal_release must be called ** if we error out of the mount */ } if (reread_meta_blocks(s)) { printk("reiserfs_read_super: unable to reread meta blocks after journal init\n") ; goto error ; } if (replay_only (s)) goto error; if (is_read_only(s->s_dev) && !(s->s_flags & MS_RDONLY)) { printk("clm-7000: Detected readonly device, marking FS readonly\n") ; s->s_flags |= MS_RDONLY ; } args.objectid = REISERFS_ROOT_PARENT_OBJECTID ; root_inode = iget4 (s, REISERFS_ROOT_OBJECTID, 0, (void *)(&args)); if (!root_inode) { printk ("reiserfs_read_super: get root inode failed\n"); goto error; } s->s_root = d_alloc_root(root_inode); if (!s->s_root) { iput(root_inode); goto error; } // define and initialize hash function s->u.reiserfs_sb.s_hash_function = hash_function (s); if (s->u.reiserfs_sb.s_hash_function == NULL) { dput(s->s_root) ; s->s_root = NULL ; goto error ; } rs = SB_DISK_SUPER_BLOCK (s); old_magic = strncmp (rs->s_magic, REISER2FS_SUPER_MAGIC_STRING, strlen ( REISER2FS_SUPER_MAGIC_STRING)); if (!old_magic) set_bit(REISERFS_3_6, &(s->u.reiserfs_sb.s_properties)); else set_bit(REISERFS_3_5, &(s->u.reiserfs_sb.s_properties)); if (!(s->s_flags & MS_RDONLY)) { journal_begin(&th, s, 1) ; reiserfs_prepare_for_journal(s, SB_BUFFER_WITH_SB(s), 1) ; set_sb_state( rs, REISERFS_ERROR_FS ); if ( old_magic ) { // filesystem created under 3.5.x found if (convert_reiserfs (s)) { reiserfs_warning("reiserfs: converting 3.5.x filesystem to the new format\n") ; // after this 3.5.x will not be able to mount this partition memcpy (rs->s_magic, REISER2FS_SUPER_MAGIC_STRING, sizeof (REISER2FS_SUPER_MAGIC_STRING)); reiserfs_convert_objectid_map_v1(s) ; set_bit(REISERFS_3_6, &(s->u.reiserfs_sb.s_properties)); clear_bit(REISERFS_3_5, &(s->u.reiserfs_sb.s_properties)); } else { reiserfs_warning("reiserfs: using 3.5.x disk format\n") ; } } journal_mark_dirty(&th, s, SB_BUFFER_WITH_SB (s)); journal_end(&th, s, 1) ; /* look for files which were to be removed in previous session */ finish_unfinished (s); s->s_dirt = 0; } else { if ( old_magic ) { reiserfs_warning("reiserfs: using 3.5.x disk format\n") ; } } // mark hash in super block: it could be unset. overwrite should be ok set_sb_hash_function_code( rs, function2code(s->u.reiserfs_sb.s_hash_function ) ); handle_attrs( s ); reiserfs_proc_info_init( s ); reiserfs_proc_register( s, "version", reiserfs_version_in_proc ); reiserfs_proc_register( s, "super", reiserfs_super_in_proc ); reiserfs_proc_register( s, "per-level", reiserfs_per_level_in_proc ); reiserfs_proc_register( s, "bitmap", reiserfs_bitmap_in_proc ); reiserfs_proc_register( s, "on-disk-super", reiserfs_on_disk_super_in_proc ); reiserfs_proc_register( s, "oidmap", reiserfs_oidmap_in_proc ); reiserfs_proc_register( s, "journal", reiserfs_journal_in_proc ); init_waitqueue_head (&(s->u.reiserfs_sb.s_wait)); printk("%s\n", reiserfs_get_version_string()) ; return s; error: if (jinit_done) { /* kill the commit thread, free journal ram */ journal_release_error(NULL, s) ; } if (SB_DISK_SUPER_BLOCK (s)) { for (j = 0; j < SB_BMAP_NR (s); j ++) { if (SB_AP_BITMAP (s)) brelse (SB_AP_BITMAP (s)[j]); } if (SB_AP_BITMAP (s)) reiserfs_kfree (SB_AP_BITMAP (s), sizeof (struct buffer_head *) * SB_BMAP_NR (s), s); } if (SB_BUFFER_WITH_SB (s)) brelse(SB_BUFFER_WITH_SB (s)); return NULL; }