diff options
Diffstat (limited to 'fs/udf')
-rw-r--r-- | fs/udf/namei.c | 145 | ||||
-rw-r--r-- | fs/udf/partition.c | 4 | ||||
-rw-r--r-- | fs/udf/super.c | 1 | ||||
-rw-r--r-- | fs/udf/udfdecl.h | 1 |
4 files changed, 145 insertions, 6 deletions
diff --git a/fs/udf/namei.c b/fs/udf/namei.c index 2b34c8ca6c83..d3231947db19 100644 --- a/fs/udf/namei.c +++ b/fs/udf/namei.c | |||
@@ -32,6 +32,7 @@ | |||
32 | #include <linux/buffer_head.h> | 32 | #include <linux/buffer_head.h> |
33 | #include <linux/sched.h> | 33 | #include <linux/sched.h> |
34 | #include <linux/crc-itu-t.h> | 34 | #include <linux/crc-itu-t.h> |
35 | #include <linux/exportfs.h> | ||
35 | 36 | ||
36 | static inline int udf_match(int len1, const char *name1, int len2, | 37 | static inline int udf_match(int len1, const char *name1, int len2, |
37 | const char *name2) | 38 | const char *name2) |
@@ -158,6 +159,8 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
158 | sector_t offset; | 159 | sector_t offset; |
159 | struct extent_position epos = {}; | 160 | struct extent_position epos = {}; |
160 | struct udf_inode_info *dinfo = UDF_I(dir); | 161 | struct udf_inode_info *dinfo = UDF_I(dir); |
162 | int isdotdot = dentry->d_name.len == 2 && | ||
163 | dentry->d_name.name[0] == '.' && dentry->d_name.name[1] == '.'; | ||
161 | 164 | ||
162 | size = udf_ext0_offset(dir) + dir->i_size; | 165 | size = udf_ext0_offset(dir) + dir->i_size; |
163 | f_pos = udf_ext0_offset(dir); | 166 | f_pos = udf_ext0_offset(dir); |
@@ -225,6 +228,12 @@ static struct fileIdentDesc *udf_find_entry(struct inode *dir, | |||
225 | continue; | 228 | continue; |
226 | } | 229 | } |
227 | 230 | ||
231 | if ((cfi->fileCharacteristics & FID_FILE_CHAR_PARENT) && | ||
232 | isdotdot) { | ||
233 | brelse(epos.bh); | ||
234 | return fi; | ||
235 | } | ||
236 | |||
228 | if (!lfi) | 237 | if (!lfi) |
229 | continue; | 238 | continue; |
230 | 239 | ||
@@ -286,9 +295,8 @@ static struct dentry *udf_lookup(struct inode *dir, struct dentry *dentry, | |||
286 | } | 295 | } |
287 | } | 296 | } |
288 | unlock_kernel(); | 297 | unlock_kernel(); |
289 | d_add(dentry, inode); | ||
290 | 298 | ||
291 | return NULL; | 299 | return d_splice_alias(inode, dentry); |
292 | } | 300 | } |
293 | 301 | ||
294 | static struct fileIdentDesc *udf_add_entry(struct inode *dir, | 302 | static struct fileIdentDesc *udf_add_entry(struct inode *dir, |
@@ -307,7 +315,7 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
307 | uint16_t liu; | 315 | uint16_t liu; |
308 | int block; | 316 | int block; |
309 | kernel_lb_addr eloc; | 317 | kernel_lb_addr eloc; |
310 | uint32_t elen; | 318 | uint32_t elen = 0; |
311 | sector_t offset; | 319 | sector_t offset; |
312 | struct extent_position epos = {}; | 320 | struct extent_position epos = {}; |
313 | struct udf_inode_info *dinfo; | 321 | struct udf_inode_info *dinfo; |
@@ -398,7 +406,8 @@ static struct fileIdentDesc *udf_add_entry(struct inode *dir, | |||
398 | } | 406 | } |
399 | 407 | ||
400 | add: | 408 | add: |
401 | if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB) { | 409 | /* Is there any extent whose size we need to round up? */ |
410 | if (dinfo->i_alloc_type != ICBTAG_FLAG_AD_IN_ICB && elen) { | ||
402 | elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1); | 411 | elen = (elen + sb->s_blocksize - 1) & ~(sb->s_blocksize - 1); |
403 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) | 412 | if (dinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) |
404 | epos.offset -= sizeof(short_ad); | 413 | epos.offset -= sizeof(short_ad); |
@@ -1232,6 +1241,134 @@ end_rename: | |||
1232 | return retval; | 1241 | return retval; |
1233 | } | 1242 | } |
1234 | 1243 | ||
1244 | static struct dentry *udf_get_parent(struct dentry *child) | ||
1245 | { | ||
1246 | struct dentry *parent; | ||
1247 | struct inode *inode = NULL; | ||
1248 | struct dentry dotdot; | ||
1249 | struct fileIdentDesc cfi; | ||
1250 | struct udf_fileident_bh fibh; | ||
1251 | |||
1252 | dotdot.d_name.name = ".."; | ||
1253 | dotdot.d_name.len = 2; | ||
1254 | |||
1255 | lock_kernel(); | ||
1256 | if (!udf_find_entry(child->d_inode, &dotdot, &fibh, &cfi)) | ||
1257 | goto out_unlock; | ||
1258 | |||
1259 | if (fibh.sbh != fibh.ebh) | ||
1260 | brelse(fibh.ebh); | ||
1261 | brelse(fibh.sbh); | ||
1262 | |||
1263 | inode = udf_iget(child->d_inode->i_sb, | ||
1264 | lelb_to_cpu(cfi.icb.extLocation)); | ||
1265 | if (!inode) | ||
1266 | goto out_unlock; | ||
1267 | unlock_kernel(); | ||
1268 | |||
1269 | parent = d_alloc_anon(inode); | ||
1270 | if (!parent) { | ||
1271 | iput(inode); | ||
1272 | parent = ERR_PTR(-ENOMEM); | ||
1273 | } | ||
1274 | |||
1275 | return parent; | ||
1276 | out_unlock: | ||
1277 | unlock_kernel(); | ||
1278 | return ERR_PTR(-EACCES); | ||
1279 | } | ||
1280 | |||
1281 | |||
1282 | static struct dentry *udf_nfs_get_inode(struct super_block *sb, u32 block, | ||
1283 | u16 partref, __u32 generation) | ||
1284 | { | ||
1285 | struct inode *inode; | ||
1286 | struct dentry *result; | ||
1287 | kernel_lb_addr loc; | ||
1288 | |||
1289 | if (block == 0) | ||
1290 | return ERR_PTR(-ESTALE); | ||
1291 | |||
1292 | loc.logicalBlockNum = block; | ||
1293 | loc.partitionReferenceNum = partref; | ||
1294 | inode = udf_iget(sb, loc); | ||
1295 | |||
1296 | if (inode == NULL) | ||
1297 | return ERR_PTR(-ENOMEM); | ||
1298 | |||
1299 | if (generation && inode->i_generation != generation) { | ||
1300 | iput(inode); | ||
1301 | return ERR_PTR(-ESTALE); | ||
1302 | } | ||
1303 | result = d_alloc_anon(inode); | ||
1304 | if (!result) { | ||
1305 | iput(inode); | ||
1306 | return ERR_PTR(-ENOMEM); | ||
1307 | } | ||
1308 | return result; | ||
1309 | } | ||
1310 | |||
1311 | static struct dentry *udf_fh_to_dentry(struct super_block *sb, | ||
1312 | struct fid *fid, int fh_len, int fh_type) | ||
1313 | { | ||
1314 | if ((fh_len != 3 && fh_len != 5) || | ||
1315 | (fh_type != FILEID_UDF_WITH_PARENT && | ||
1316 | fh_type != FILEID_UDF_WITHOUT_PARENT)) | ||
1317 | return NULL; | ||
1318 | |||
1319 | return udf_nfs_get_inode(sb, fid->udf.block, fid->udf.partref, | ||
1320 | fid->udf.generation); | ||
1321 | } | ||
1322 | |||
1323 | static struct dentry *udf_fh_to_parent(struct super_block *sb, | ||
1324 | struct fid *fid, int fh_len, int fh_type) | ||
1325 | { | ||
1326 | if (fh_len != 5 || fh_type != FILEID_UDF_WITH_PARENT) | ||
1327 | return NULL; | ||
1328 | |||
1329 | return udf_nfs_get_inode(sb, fid->udf.parent_block, | ||
1330 | fid->udf.parent_partref, | ||
1331 | fid->udf.parent_generation); | ||
1332 | } | ||
1333 | static int udf_encode_fh(struct dentry *de, __u32 *fh, int *lenp, | ||
1334 | int connectable) | ||
1335 | { | ||
1336 | int len = *lenp; | ||
1337 | struct inode *inode = de->d_inode; | ||
1338 | kernel_lb_addr location = UDF_I(inode)->i_location; | ||
1339 | struct fid *fid = (struct fid *)fh; | ||
1340 | int type = FILEID_UDF_WITHOUT_PARENT; | ||
1341 | |||
1342 | if (len < 3 || (connectable && len < 5)) | ||
1343 | return 255; | ||
1344 | |||
1345 | *lenp = 3; | ||
1346 | fid->udf.block = location.logicalBlockNum; | ||
1347 | fid->udf.partref = location.partitionReferenceNum; | ||
1348 | fid->udf.generation = inode->i_generation; | ||
1349 | |||
1350 | if (connectable && !S_ISDIR(inode->i_mode)) { | ||
1351 | spin_lock(&de->d_lock); | ||
1352 | inode = de->d_parent->d_inode; | ||
1353 | location = UDF_I(inode)->i_location; | ||
1354 | fid->udf.parent_block = location.logicalBlockNum; | ||
1355 | fid->udf.parent_partref = location.partitionReferenceNum; | ||
1356 | fid->udf.parent_generation = inode->i_generation; | ||
1357 | spin_unlock(&de->d_lock); | ||
1358 | *lenp = 5; | ||
1359 | type = FILEID_UDF_WITH_PARENT; | ||
1360 | } | ||
1361 | |||
1362 | return type; | ||
1363 | } | ||
1364 | |||
1365 | const struct export_operations udf_export_ops = { | ||
1366 | .encode_fh = udf_encode_fh, | ||
1367 | .fh_to_dentry = udf_fh_to_dentry, | ||
1368 | .fh_to_parent = udf_fh_to_parent, | ||
1369 | .get_parent = udf_get_parent, | ||
1370 | }; | ||
1371 | |||
1235 | const struct inode_operations udf_dir_inode_operations = { | 1372 | const struct inode_operations udf_dir_inode_operations = { |
1236 | .lookup = udf_lookup, | 1373 | .lookup = udf_lookup, |
1237 | .create = udf_create, | 1374 | .create = udf_create, |
diff --git a/fs/udf/partition.c b/fs/udf/partition.c index 63610f026ae1..96dfd207c3d6 100644 --- a/fs/udf/partition.c +++ b/fs/udf/partition.c | |||
@@ -27,8 +27,8 @@ | |||
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/buffer_head.h> | 28 | #include <linux/buffer_head.h> |
29 | 29 | ||
30 | inline uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, | 30 | uint32_t udf_get_pblock(struct super_block *sb, uint32_t block, |
31 | uint16_t partition, uint32_t offset) | 31 | uint16_t partition, uint32_t offset) |
32 | { | 32 | { |
33 | struct udf_sb_info *sbi = UDF_SB(sb); | 33 | struct udf_sb_info *sbi = UDF_SB(sb); |
34 | struct udf_part_map *map; | 34 | struct udf_part_map *map; |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 9fb18a340fc1..7a5f69be6ac2 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
@@ -1933,6 +1933,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent) | |||
1933 | 1933 | ||
1934 | /* Fill in the rest of the superblock */ | 1934 | /* Fill in the rest of the superblock */ |
1935 | sb->s_op = &udf_sb_ops; | 1935 | sb->s_op = &udf_sb_ops; |
1936 | sb->s_export_op = &udf_export_ops; | ||
1936 | sb->dq_op = NULL; | 1937 | sb->dq_op = NULL; |
1937 | sb->s_dirt = 0; | 1938 | sb->s_dirt = 0; |
1938 | sb->s_magic = UDF_SUPER_MAGIC; | 1939 | sb->s_magic = UDF_SUPER_MAGIC; |
diff --git a/fs/udf/udfdecl.h b/fs/udf/udfdecl.h index f3f45d029277..8fa9c2d70911 100644 --- a/fs/udf/udfdecl.h +++ b/fs/udf/udfdecl.h | |||
@@ -73,6 +73,7 @@ struct task_struct; | |||
73 | struct buffer_head; | 73 | struct buffer_head; |
74 | struct super_block; | 74 | struct super_block; |
75 | 75 | ||
76 | extern const struct export_operations udf_export_ops; | ||
76 | extern const struct inode_operations udf_dir_inode_operations; | 77 | extern const struct inode_operations udf_dir_inode_operations; |
77 | extern const struct file_operations udf_dir_operations; | 78 | extern const struct file_operations udf_dir_operations; |
78 | extern const struct inode_operations udf_file_inode_operations; | 79 | extern const struct inode_operations udf_file_inode_operations; |