ext3_bread is safe for meta-data blocks. it's not safe to read file data, since file data is managed by file cache, not volume cache */
| 228 | /* ext3_bread is safe for meta-data blocks. it's not safe to read file data, |
| 229 | since file data is managed by file cache, not volume cache */ |
| 230 | struct buffer_head *ext3_bread(struct ext2_icb *icb, struct inode *inode, |
| 231 | unsigned long block, int *err) |
| 232 | { |
| 233 | struct buffer_head * bh = NULL; |
| 234 | NTSTATUS status = STATUS_SUCCESS; |
| 235 | ULONG lbn = 0, num = 0; |
| 236 | |
| 237 | PEXT2_MCB Mcb = CONTAINING_RECORD(inode, EXT2_MCB, Inode); |
| 238 | |
| 239 | /* for symlink file, read it's target instead */ |
| 240 | if (NULL != Mcb && IsMcbSymLink(Mcb)) |
| 241 | Mcb = Mcb->Target; |
| 242 | if (NULL == Mcb) { |
| 243 | *err = -EINVAL; |
| 244 | return NULL; |
| 245 | } |
| 246 | |
| 247 | /* mapping file offset to ext2 block */ |
| 248 | if (INODE_HAS_EXTENT(&Mcb->Inode)) { |
| 249 | status = Ext2MapExtent(icb, inode->i_sb->s_priv, |
| 250 | Mcb, block, FALSE, |
| 251 | &lbn, &num); |
| 252 | } else { |
| 253 | status = Ext2MapIndirect(icb, inode->i_sb->s_priv, |
| 254 | Mcb, block, FALSE, |
| 255 | &lbn, &num); |
| 256 | } |
| 257 | |
| 258 | if (!NT_SUCCESS(status)) { |
| 259 | *err = Ext2LinuxError(status); |
| 260 | return bh; |
| 261 | } |
| 262 | |
| 263 | bh = sb_getblk(inode->i_sb, lbn); |
| 264 | if (!bh) { |
| 265 | *err = -ENOMEM; |
| 266 | return bh; |
| 267 | } |
| 268 | if (buffer_uptodate(bh)) |
| 269 | return bh; |
| 270 | |
| 271 | *err = bh_submit_read(bh); |
| 272 | if (*err) { |
| 273 | __brelse(bh); |
| 274 | return NULL; |
| 275 | } |
| 276 | return bh; |
| 277 | } |
| 278 | |
| 279 | struct buffer_head *ext3_append(struct ext2_icb *icb, struct inode *inode, |
| 280 | ext3_lblk_t *block, int *err) |
no test coverage detected