Is this a problem?

• 本文约 141 字,阅读大致需要 1 分钟 | *nix and Win32 Kernel

While reading the snapshot code in FFS Soft Updates’s FreeBSD implementation, I got a question about the following code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
		/*
		 * If there is a fragment, clear it here.
		 */
		blkno = 0;
		loc = howmany(xp->i_size, fs->fs_bsize) - 1;
		if (loc < NDADDR) {
			__len = fragroundup(fs, blkoff(fs, xp->i\_size));__
			if (len < fs->fs_bsize) {
				ffs_blkfree(copy_fs, vp, DIP(xp, i_db[loc]),
				    len, xp->i_number);
				blkno = DIP(xp, i_db[loc]);
				DIP_SET(xp, i_db[loc], 0);
			}
		}

The code indicated with bold is what I have question on. Isn’t it possible to get a zero if the unlinked file is zero-sized? If so, then what will happen when doing ffs_blkfree()?

My intention is to modify the if statement like this:

if ((len != 0) && len < (fs->fs_base))

I have e-mailed Kirk about this issue.