9 #include <linux/slab.h>
24 #define SIG(A,B) ((A) | ((B) << 8))
43 if (rr->
u.
SP.magic[0] != 0xbe)
45 if (rr->
u.
SP.magic[1] != 0xef)
47 ISOFS_SB(inode->
i_sb)->s_rock_offset = rr->
u.
SP.skip;
57 rs->
chr = (
unsigned char *)de + rs->
len;
58 rs->
len = *((
unsigned char *)de) - rs->
len;
62 if (ISOFS_SB(inode->
i_sb)->s_rock_offset != -1) {
63 rs->
len -= ISOFS_SB(inode->
i_sb)->s_rock_offset;
64 rs->
chr += ISOFS_SB(inode->
i_sb)->s_rock_offset;
70 static void init_rock_state(
struct rock_state *rs,
struct inode *inode)
72 memset(rs, 0,
sizeof(*rs));
80 static int rock_continue(
struct rock_state *rs)
83 int blocksize = 1 << rs->
inode->i_blkbits;
89 if ((
unsigned)rs->
cont_offset > blocksize - min_de_size ||
93 "extent=%d, offset=%d, size=%d\n",
100 struct buffer_head *bh;
120 printk(
"Unable to read rock-ridge attributes\n");
132 static int rock_check_overflow(
struct rock_state *rs,
int sig)
192 char *retname,
struct inode *inode)
201 if (!ISOFS_SB(inode->
i_sb)->s_rock)
205 init_rock_state(&rs, inode);
206 setup_rock_ridge(de, inode, &rs);
218 sig = isonum_721(rs.
chr);
219 if (rock_check_overflow(&rs, sig))
232 if ((rr->
u.
RR.flags[0] &
RR_NM) == 0)
236 if (check_sp(rr, inode))
256 if (rr->
u.
NM.flags & 6)
259 if (rr->
u.
NM.flags & ~1) {
260 printk(
"Unsupported NM flag settings (%d)\n",
264 if ((
strlen(retname) + rr->
len - 5) >= 254) {
269 retnamlen += rr->
len - 5;
278 ret = rock_continue(&rs);
293 struct inode *inode,
int regard_xa)
303 if (!ISOFS_SB(inode->
i_sb)->s_rock)
306 init_rock_state(&rs, inode);
307 setup_rock_ridge(de, inode, &rs);
325 sig = isonum_721(rs.
chr);
326 if (rock_check_overflow(&rs, sig))
338 #ifndef CONFIG_ZISOFS
346 if (check_sp(rr, inode))
350 rs.cont_extent = isonum_733(rr->
u.
CE.
extent);
355 ISOFS_SB(inode->i_sb)->s_rock = 1;
359 for (p = 0; p < rr->
u.
ER.len_id; p++)
365 inode->i_mode = isonum_733(rr->
u.
PX.
mode);
367 i_uid_write(inode, isonum_733(rr->
u.
PX.uid));
368 i_gid_write(inode, isonum_733(rr->
u.
PX.gid));
373 high = isonum_733(rr->
u.
PN.dev_high);
374 low = isonum_733(rr->
u.
PN.dev_low);
385 if ((low & ~0xff) && high == 0) {
387 MKDEV(low >> 8, low & 0xff);
433 slp = &rr->
u.
SL.link;
434 inode->
i_size = symlink_len;
437 switch (slp->
flags & ~1) {
453 printk(
"Symlink component flag "
454 "not implemented\n");
456 slen -= slp->
len + 2;
459 (((
char *)slp) + slp->
len + 2);
477 && (oldslp->
flags & 1) == 0)
481 symlink_len = inode->
i_size;
485 "relocated directory\n");
488 ISOFS_I(inode)->i_first_extent =
492 ISOFS_I(inode)->i_first_extent,
495 ret = PTR_ERR(reloc);
511 case SIG(
'Z',
'F'): {
514 if (ISOFS_SB(inode->
i_sb)->s_nocompress)
516 algo = isonum_721(rr->
u.
ZF.algorithm);
517 if (algo ==
SIG(
'p',
'z')) {
519 isonum_711(&rr->
u.
ZF.parms[1]);
520 if (block_shift > 17) {
522 "Can't handle ZF block "
530 ISOFS_I(inode)->i_file_format =
537 ISOFS_I(inode)->i_format_parm[0] =
538 isonum_711(&rr->
u.
ZF.parms[0]);
539 ISOFS_I(inode)->i_format_parm[1] =
540 isonum_711(&rr->
u.
ZF.parms[1]);
547 "isofs: Unknown ZF compression "
549 rr->
u.
ZF.algorithm[0],
550 rr->
u.
ZF.algorithm[1]);
559 ret = rock_continue(&rs);
572 static char *get_symlink_chunk(
char *rpnt,
struct rock_ridge *rr,
char *plimit)
579 slp = &rr->
u.
SL.link;
582 switch (slp->
flags & ~1) {
584 if (slp->
len > plimit - rpnt)
595 if (2 > plimit - rpnt)
607 printk(
"Symlink component flag not implemented (%d)\n",
610 slen -= slp->
len + 2;
619 if ((!rootflag) && (rr->
u.
SL.flags & 1) &&
620 !(oldslp->
flags & 1)) {
631 if (!rootflag && !(oldslp->
flags & 1)) {
642 int result = parse_rock_ridge_inode_internal(de, inode, 0);
648 if ((ISOFS_SB(inode->
i_sb)->s_rock_offset == -1)
649 && (ISOFS_SB(inode->
i_sb)->s_rock == 2)) {
650 result = parse_rock_ridge_inode_internal(de, inode, 14);
659 static int rock_ridge_symlink_readpage(
struct file *
file,
struct page *
page)
661 struct inode *inode = page->
mapping->host;
666 struct buffer_head *bh;
679 init_rock_state(&rs, inode);
681 bh = sb_bread(inode->
i_sb, block);
686 pnt = (
unsigned char *)bh->b_data + offset;
693 if (offset + *pnt > bufsize)
701 setup_rock_ridge(raw_de, inode, &rs);
708 sig = isonum_721(rs.
chr);
709 if (rock_check_overflow(&rs, sig))
722 if (check_sp(rr, inode))
726 rpnt = get_symlink_chunk(rpnt, rr,
733 rs.cont_extent = isonum_733(rr->
u.
CE.
extent);
740 ret = rock_continue(&rs);
750 SetPageUptodate(page);
760 printk(
"unable to read i-node block");
763 printk(
"symlink spans iso9660 blocks\n");
774 .readpage = rock_ridge_symlink_readpage