aboutsummaryrefslogtreecommitdiffstats
path: root/fs/squashfs/inode.c
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@lougher.demon.co.uk>2010-05-16 23:06:56 -0400
committerPhillip Lougher <phillip@lougher.demon.co.uk>2010-05-17 14:54:06 -0400
commit67f66cc6c728de183d9d43c243cb163c1ebd8e04 (patch)
treebd175ed5f66594ad76d099461560c3fe8a01181c /fs/squashfs/inode.c
parentf41d207cbedecd82f797adcce83890aa96f1c9e9 (diff)
squashfs: add new extended inode types
Add new extended inode types that store the xattr_id field. Also add the necessary code changes to make xattrs visibile. Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
Diffstat (limited to 'fs/squashfs/inode.c')
-rw-r--r--fs/squashfs/inode.c91
1 files changed, 84 insertions, 7 deletions
diff --git a/fs/squashfs/inode.c b/fs/squashfs/inode.c
index 49daaf669e41..250701180a3b 100644
--- a/fs/squashfs/inode.c
+++ b/fs/squashfs/inode.c
@@ -40,6 +40,7 @@
40 40
41#include <linux/fs.h> 41#include <linux/fs.h>
42#include <linux/vfs.h> 42#include <linux/vfs.h>
43#include <linux/xattr.h>
43 44
44#include "squashfs_fs.h" 45#include "squashfs_fs.h"
45#include "squashfs_fs_sb.h" 46#include "squashfs_fs_sb.h"
@@ -111,6 +112,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
111 int err, type, offset = SQUASHFS_INODE_OFFSET(ino); 112 int err, type, offset = SQUASHFS_INODE_OFFSET(ino);
112 union squashfs_inode squashfs_ino; 113 union squashfs_inode squashfs_ino;
113 struct squashfs_base_inode *sqshb_ino = &squashfs_ino.base; 114 struct squashfs_base_inode *sqshb_ino = &squashfs_ino.base;
115 int xattr_id = SQUASHFS_INVALID_XATTR;
114 116
115 TRACE("Entered squashfs_read_inode\n"); 117 TRACE("Entered squashfs_read_inode\n");
116 118
@@ -199,8 +201,10 @@ int squashfs_read_inode(struct inode *inode, long long ino)
199 frag_offset = 0; 201 frag_offset = 0;
200 } 202 }
201 203
204 xattr_id = le32_to_cpu(sqsh_ino->xattr);
202 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 205 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink);
203 inode->i_size = le64_to_cpu(sqsh_ino->file_size); 206 inode->i_size = le64_to_cpu(sqsh_ino->file_size);
207 inode->i_op = &squashfs_inode_ops;
204 inode->i_fop = &generic_ro_fops; 208 inode->i_fop = &generic_ro_fops;
205 inode->i_mode |= S_IFREG; 209 inode->i_mode |= S_IFREG;
206 inode->i_blocks = ((inode->i_size - 210 inode->i_blocks = ((inode->i_size -
@@ -251,6 +255,7 @@ int squashfs_read_inode(struct inode *inode, long long ino)
251 if (err < 0) 255 if (err < 0)
252 goto failed_read; 256 goto failed_read;
253 257
258 xattr_id = le32_to_cpu(sqsh_ino->xattr);
254 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 259 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink);
255 inode->i_size = le32_to_cpu(sqsh_ino->file_size); 260 inode->i_size = le32_to_cpu(sqsh_ino->file_size);
256 inode->i_op = &squashfs_dir_inode_ops; 261 inode->i_op = &squashfs_dir_inode_ops;
@@ -280,21 +285,33 @@ int squashfs_read_inode(struct inode *inode, long long ino)
280 285
281 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink); 286 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink);
282 inode->i_size = le32_to_cpu(sqsh_ino->symlink_size); 287 inode->i_size = le32_to_cpu(sqsh_ino->symlink_size);
283 inode->i_op = &page_symlink_inode_operations; 288 inode->i_op = &squashfs_symlink_inode_ops;
284 inode->i_data.a_ops = &squashfs_symlink_aops; 289 inode->i_data.a_ops = &squashfs_symlink_aops;
285 inode->i_mode |= S_IFLNK; 290 inode->i_mode |= S_IFLNK;
286 squashfs_i(inode)->start = block; 291 squashfs_i(inode)->start = block;
287 squashfs_i(inode)->offset = offset; 292 squashfs_i(inode)->offset = offset;
288 293
294 if (type == SQUASHFS_LSYMLINK_TYPE) {
295 __le32 xattr;
296
297 err = squashfs_read_metadata(sb, NULL, &block,
298 &offset, inode->i_size);
299 if (err < 0)
300 goto failed_read;
301 err = squashfs_read_metadata(sb, &xattr, &block,
302 &offset, sizeof(xattr));
303 if (err < 0)
304 goto failed_read;
305 xattr_id = le32_to_cpu(xattr);
306 }
307
289 TRACE("Symbolic link inode %x:%x, start_block %llx, offset " 308 TRACE("Symbolic link inode %x:%x, start_block %llx, offset "
290 "%x\n", SQUASHFS_INODE_BLK(ino), offset, 309 "%x\n", SQUASHFS_INODE_BLK(ino), offset,
291 block, offset); 310 block, offset);
292 break; 311 break;
293 } 312 }
294 case SQUASHFS_BLKDEV_TYPE: 313 case SQUASHFS_BLKDEV_TYPE:
295 case SQUASHFS_CHRDEV_TYPE: 314 case SQUASHFS_CHRDEV_TYPE: {
296 case SQUASHFS_LBLKDEV_TYPE:
297 case SQUASHFS_LCHRDEV_TYPE: {
298 struct squashfs_dev_inode *sqsh_ino = &squashfs_ino.dev; 315 struct squashfs_dev_inode *sqsh_ino = &squashfs_ino.dev;
299 unsigned int rdev; 316 unsigned int rdev;
300 317
@@ -315,10 +332,32 @@ int squashfs_read_inode(struct inode *inode, long long ino)
315 SQUASHFS_INODE_BLK(ino), offset, rdev); 332 SQUASHFS_INODE_BLK(ino), offset, rdev);
316 break; 333 break;
317 } 334 }
335 case SQUASHFS_LBLKDEV_TYPE:
336 case SQUASHFS_LCHRDEV_TYPE: {
337 struct squashfs_ldev_inode *sqsh_ino = &squashfs_ino.ldev;
338 unsigned int rdev;
339
340 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset,
341 sizeof(*sqsh_ino));
342 if (err < 0)
343 goto failed_read;
344
345 if (type == SQUASHFS_LCHRDEV_TYPE)
346 inode->i_mode |= S_IFCHR;
347 else
348 inode->i_mode |= S_IFBLK;
349 xattr_id = le32_to_cpu(sqsh_ino->xattr);
350 inode->i_op = &squashfs_inode_ops;
351 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink);
352 rdev = le32_to_cpu(sqsh_ino->rdev);
353 init_special_inode(inode, inode->i_mode, new_decode_dev(rdev));
354
355 TRACE("Device inode %x:%x, rdev %x\n",
356 SQUASHFS_INODE_BLK(ino), offset, rdev);
357 break;
358 }
318 case SQUASHFS_FIFO_TYPE: 359 case SQUASHFS_FIFO_TYPE:
319 case SQUASHFS_SOCKET_TYPE: 360 case SQUASHFS_SOCKET_TYPE: {
320 case SQUASHFS_LFIFO_TYPE:
321 case SQUASHFS_LSOCKET_TYPE: {
322 struct squashfs_ipc_inode *sqsh_ino = &squashfs_ino.ipc; 361 struct squashfs_ipc_inode *sqsh_ino = &squashfs_ino.ipc;
323 362
324 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset, 363 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset,
@@ -334,14 +373,52 @@ int squashfs_read_inode(struct inode *inode, long long ino)
334 init_special_inode(inode, inode->i_mode, 0); 373 init_special_inode(inode, inode->i_mode, 0);
335 break; 374 break;
336 } 375 }
376 case SQUASHFS_LFIFO_TYPE:
377 case SQUASHFS_LSOCKET_TYPE: {
378 struct squashfs_lipc_inode *sqsh_ino = &squashfs_ino.lipc;
379
380 err = squashfs_read_metadata(sb, sqsh_ino, &block, &offset,
381 sizeof(*sqsh_ino));
382 if (err < 0)
383 goto failed_read;
384
385 if (type == SQUASHFS_LFIFO_TYPE)
386 inode->i_mode |= S_IFIFO;
387 else
388 inode->i_mode |= S_IFSOCK;
389 xattr_id = le32_to_cpu(sqsh_ino->xattr);
390 inode->i_op = &squashfs_inode_ops;
391 inode->i_nlink = le32_to_cpu(sqsh_ino->nlink);
392 init_special_inode(inode, inode->i_mode, 0);
393 break;
394 }
337 default: 395 default:
338 ERROR("Unknown inode type %d in squashfs_iget!\n", type); 396 ERROR("Unknown inode type %d in squashfs_iget!\n", type);
339 return -EINVAL; 397 return -EINVAL;
340 } 398 }
341 399
400 if (xattr_id != SQUASHFS_INVALID_XATTR && msblk->xattr_id_table) {
401 err = squashfs_xattr_lookup(sb, xattr_id,
402 &squashfs_i(inode)->xattr_count,
403 &squashfs_i(inode)->xattr_size,
404 &squashfs_i(inode)->xattr);
405 if (err < 0)
406 goto failed_read;
407 inode->i_blocks += ((squashfs_i(inode)->xattr_size - 1) >> 9)
408 + 1;
409 } else
410 squashfs_i(inode)->xattr_count = 0;
411
342 return 0; 412 return 0;
343 413
344failed_read: 414failed_read:
345 ERROR("Unable to read inode 0x%llx\n", ino); 415 ERROR("Unable to read inode 0x%llx\n", ino);
346 return err; 416 return err;
347} 417}
418
419
420const struct inode_operations squashfs_inode_ops = {
421 .getxattr = generic_getxattr,
422 .listxattr = squashfs_listxattr
423};
424