level 1
我的毕设,我要看下边的代码~!!!只是一部分2楼贴
2007年05月12日 17点05分
1
level 1
#defineDOEXTENT(fs, lbn, boff, bnp, lenp, size, tblp, n, chkfrag, maxtrans) {\//确定地址范围register daddr32_t *dp = (tblp);\register int _chkfrag = chkfrag; /* for lint. sigh */\\if (*dp == 0) {\*(bnp) = ;\} else {\register int len;\\len = findextent(fs, dp, (int)(n), lenp, maxtrans) << \//得到文件长度(fs)->fs_bshift; \if (_chkfrag) {\register u_offset_t tmp;\\tmp = fragroundup((fs), size) -\ (((u_offset_t)lbn) << fs->fs_bshift);\len = (int)MIN(tmp, len);\}\len -= (boff);\if (len <= 0) {\*(bnp) = UFS_HOLE;\} else {\*(bnp) = fsbtodb(fs, *dp) + btodb(boff);\*(lenp) = len;\}\}\}
2007年05月12日 17点05分
2
level 1
int bmap_write(struct inode*ip,u_offset_t off,int size,int alloc_only,struct cred*cr){structfs *fs;structbuf *
bp
;inti;structbuf *nbp;intj;intshft;/* we maintain sh = 1 << shft */daddr_tob, nb, pref, lbn, llbn, tbn;daddr32_t *bap;structvnode *vp = ITOV(ip);longbsize = VBSIZE(vp);longosize, nsize;intissync, metaflag, isdirquota;interr;dev_tdev;structfbuf *fbp;intnindirshift;intnindiroffset;structufsvfs*ufsvfsp;intadded_sectors;/* sectors added to this inode */intalloced_blocks;/* fs blocks newly allocated */struct ufs_allocated_block undo_table[NIADDR+1];intverylargefile = 0;ASSERT(RW_WRITE_HELD(&ip->i_contents));ufsvfsp = ip->i_ufsvfs;fs = ufsvfsp->vfs_bufp->b_un.b_fs;lbn = (daddr_t)lblkno(fs, off);if (lbn < 0)return (EFBIG);if (ip->i_blocks >= VERYLARGEFILESIZE)verylargefile = 1;llbn = (daddr_t)((ip->i_size) ? lblkno(fs, ip->i_size - 1) : 0);metaflag = isdirquota = 0;if (((ip->i_mode & IFMT) == IFDIR) || ((ip->i_mode & IFMT) == IFATTRDIR))isdirquota = metaflag = I_DIR;else if ((ip->i_mode & IFMT) == IFSHAD)metaflag = I_SHAD;else if (ip->i_ufsvfs->vfs_qinod == ip)isdirquota = metaflag = I_QUOTA;issync = ((ip->i_flag & ISYNC) != 0);if (isdirquota || issync) {alloc_only = 0;/* make sure */}/* * If the next write will extend the file into a new block, * and the file is currently composed of a fragment * this fragment has to be extended to be a full block. */if (llbn < NDADDR && llbn < lbn && (ob = ip->i_db[llbn]) != 0) {osize = blksize(fs, ip, llbn);if (osize < bsize && osize > 0) {/* * Check to see if doing this will make the file too * big. Only check if we are dealing with a very * large file. */if (verylargefile == 1) {if (((unsigned)ip->i_blocks + btodb(bsize - osize)) > INT_MAX) {return (EFBIG);}}/* * Make sure we have all needed pages setup correctly. * * We pass S_OTHER to fbread here because we want * an exclusive lock on the page in question * (see ufs_getpage). I/O to the old block location * may still be in progress and we are about to free * the old block. We don't want anyone else to get * a hold of the old block once we free it until * the I/O is complete. */err = fbread(ITOV(ip), ((offset_t)llbn << fs->fs_bshift),(uint_t)bsize, S_OTHER, &fbp);if (err)return (err);pref = blkpref(ip, llbn, (int)llbn, &ip->i_db[0]);err = realloccg(ip, ob, pref, (int)osize, (int)bsize,&nb, cr);if (err) {if (fbp)fbrelse(fbp, S_OTHER);return (err);}ASSERT(!ufs_badblock(ip, nb));
2007年05月12日 17点05分
3
level 1
/* * Update the inode before releasing the * lock on the page. If we released the page * lock first, the data could be written to it's * old address and then destroyed. */TRANS_MATA_ALLOC(ufsvfsp, ip, nb, bsize, 0);ip->i_db[llbn] = nb;UFS_SET_ISIZE(((u_offset_t)(llbn + 1)) << fs->fs_bshift, ip);ip->i_blocks += btodb(bsize - osize);ASSERT((unsigned)ip->i_blocks <= INT_MAX);TRANS_INODE(ufsvfsp, ip);ip->i_flag |= IUPD | ICHG | IATTCHG;/* Caller is responsible for updating i_seq *//* * Don't check metaflag here, directories won't do this * */if (issync) {(void) ufs_fbiwrite(fbp, ip, nb, fs->fs_fsize);} else {ASSERT(fbp);fbrelse(fbp, S_WRITE);}if (nb != ob) {(void) free(ip, ob, (off_t)osize, metaflag);}}}
2007年05月12日 17点05分
4
level 1
/* * The first NDADDR blocks are direct blocks. */if (lbn < NDADDR) {nb = ip->i_db[lbn];if (nb == 0 || ip->i_size < ((u_offset_t)(lbn + 1)) << fs->fs_bshift) {if (nb != 0) {/* consider need to reallocate a frag */osize = fragroundup(fs, blkoff(fs, ip->i_size));nsize = fragroundup(fs, size);if (nsize <= osize)goto gotit;/* * Check to see if doing this will make the * file too big. Only check if we are dealing * with a very large file. */if (verylargefile == 1) {if (((unsigned)ip->i_blocks + btodb(nsize - osize)) > INT_MAX) {return (EFBIG);}}/* * need to allocate a block or frag */ob = nb;pref = blkpref(ip, lbn, (int)lbn,&ip->i_db[0]);err = realloccg(ip, ob, pref, (int)osize,(int)nsize, &nb, cr);if (err)return (err);ASSERT(!ufs_badblock(ip, nb));} else {/* * need to allocate a block or frag */osize = 0;if (ip->i_size < ((u_offset_t)(lbn + 1)) << fs->fs_bshift)nsize = fragroundup(fs, size);elsensize = bsize;/* * Check to see if doing this will make the * file too big. Only check if we are dealing * with a very large file. */if (verylargefile == 1) {if (((unsigned)ip->i_blocks + btodb(nsize - osize)) > INT_MAX) {return (EFBIG);}}pref = blkpref(ip, lbn, (int)lbn, &ip->i_db[0]);err = alloc(ip, pref, (int)nsize, &nb, cr);if (err)return (err);ASSERT(!ufs_badblock(ip, nb));ob = nb;}
2007年05月12日 17点05分
5
level 1
不贴了...怕吓坏大家...就贴了一个函数....
2007年05月12日 17点05分
8
level 9
那你这程序是用来赶什么的呢???你说说用中国话!!
2007年05月12日 17点05分
11
level 1
这是一个操作系统的源代码不是我写的我是分析这些东西然后写出流程
2007年05月12日 17点05分
15
level 8
蚊子~~~~~~~来这说~~~~~~表水了人家的楼~~~~~~~~~
2007年05月12日 17点05分
18
level 9
....你真的厉害爪子你JJ我曾今很窝囊.....唉居然为闹计算机的数据库考试可以及格...都上美人计闹!靠
2007年05月12日 17点05分
20