aboutsummaryrefslogtreecommitdiffstats
path: root/fs/fat/nfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/fat/nfs.c')
-rw-r--r--fs/fat/nfs.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/fs/fat/nfs.c b/fs/fat/nfs.c
index 0748196889b2..93e14933dcb6 100644
--- a/fs/fat/nfs.c
+++ b/fs/fat/nfs.c
@@ -216,6 +216,53 @@ static struct dentry *fat_fh_to_parent_nostale(struct super_block *sb,
216} 216}
217 217
218/* 218/*
219 * Rebuild the parent for a directory that is not connected
220 * to the filesystem root
221 */
222static
223struct inode *fat_rebuild_parent(struct super_block *sb, int parent_logstart)
224{
225 int search_clus, clus_to_match;
226 struct msdos_dir_entry *de;
227 struct inode *parent = NULL;
228 struct inode *dummy_grand_parent = NULL;
229 struct fat_slot_info sinfo;
230 struct msdos_sb_info *sbi = MSDOS_SB(sb);
231 sector_t blknr = fat_clus_to_blknr(sbi, parent_logstart);
232 struct buffer_head *parent_bh = sb_bread(sb, blknr);
233 if (!parent_bh) {
234 fat_msg(sb, KERN_ERR,
235 "unable to read cluster of parent directory");
236 return NULL;
237 }
238
239 de = (struct msdos_dir_entry *) parent_bh->b_data;
240 clus_to_match = fat_get_start(sbi, &de[0]);
241 search_clus = fat_get_start(sbi, &de[1]);
242
243 dummy_grand_parent = fat_dget(sb, search_clus);
244 if (!dummy_grand_parent) {
245 dummy_grand_parent = new_inode(sb);
246 if (!dummy_grand_parent) {
247 brelse(parent_bh);
248 return parent;
249 }
250
251 dummy_grand_parent->i_ino = iunique(sb, MSDOS_ROOT_INO);
252 fat_fill_inode(dummy_grand_parent, &de[1]);
253 MSDOS_I(dummy_grand_parent)->i_pos = -1;
254 }
255
256 if (!fat_scan_logstart(dummy_grand_parent, clus_to_match, &sinfo))
257 parent = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
258
259 brelse(parent_bh);
260 iput(dummy_grand_parent);
261
262 return parent;
263}
264
265/*
219 * Find the parent for a directory that is not currently connected to 266 * Find the parent for a directory that is not currently connected to
220 * the filesystem root. 267 * the filesystem root.
221 * 268 *
@@ -227,10 +274,13 @@ static struct dentry *fat_get_parent(struct dentry *child_dir)
227 struct buffer_head *bh = NULL; 274 struct buffer_head *bh = NULL;
228 struct msdos_dir_entry *de; 275 struct msdos_dir_entry *de;
229 struct inode *parent_inode = NULL; 276 struct inode *parent_inode = NULL;
277 struct msdos_sb_info *sbi = MSDOS_SB(sb);
230 278
231 if (!fat_get_dotdot_entry(child_dir->d_inode, &bh, &de)) { 279 if (!fat_get_dotdot_entry(child_dir->d_inode, &bh, &de)) {
232 int parent_logstart = fat_get_start(MSDOS_SB(sb), de); 280 int parent_logstart = fat_get_start(sbi, de);
233 parent_inode = fat_dget(sb, parent_logstart); 281 parent_inode = fat_dget(sb, parent_logstart);
282 if (!parent_inode && sbi->options.nfs == FAT_NFS_NOSTALE_RO)
283 parent_inode = fat_rebuild_parent(sb, parent_logstart);
234 } 284 }
235 brelse(bh); 285 brelse(bh);
236 286