Blame view
fs/isofs/rock.c
18.5 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 7 8 |
/* * linux/fs/isofs/rock.c * * (C) 1992, 1993 Eric Youngdale * * Rock Ridge Extensions to iso9660 */ |
1da177e4c Linux-2.6.12-rc2 |
9 10 |
#include <linux/slab.h> #include <linux/pagemap.h> |
1da177e4c Linux-2.6.12-rc2 |
11 |
|
94f2f7157 [PATCH] isofs inc... |
12 |
#include "isofs.h" |
1da177e4c Linux-2.6.12-rc2 |
13 |
#include "rock.h" |
7373909de [PATCH] rock: com... |
14 15 |
/* * These functions are designed to read the system areas of a directory record |
1da177e4c Linux-2.6.12-rc2 |
16 17 18 19 |
* and extract relevant information. There are different functions provided * depending upon what information we need at the time. One function fills * out an inode structure, a second one extracts a filename, a third one * returns a symbolic link name, and a fourth one returns the extent number |
7373909de [PATCH] rock: com... |
20 21 |
* for the file. */ |
1da177e4c Linux-2.6.12-rc2 |
22 |
|
1d3721163 [PATCH] rock: lin... |
23 |
#define SIG(A,B) ((A) | ((B) << 8)) /* isonum_721() */ |
1da177e4c Linux-2.6.12-rc2 |
24 |
|
ba40aaf04 [PATCH] rock: rem... |
25 26 27 28 29 30 31 |
struct rock_state { void *buffer; unsigned char *chr; int len; int cont_size; int cont_extent; int cont_offset; |
f54e18f1b isofs: Fix infini... |
32 |
int cont_loops; |
ba40aaf04 [PATCH] rock: rem... |
33 34 |
struct inode *inode; }; |
12121714f [PATCH] rock: rem... |
35 36 |
/* * This is a way of ensuring that we have something in the system |
7373909de [PATCH] rock: com... |
37 |
* use fields that is compatible with Rock Ridge. Return zero on success. |
12121714f [PATCH] rock: rem... |
38 39 40 41 42 43 44 45 46 47 48 |
*/ static int check_sp(struct rock_ridge *rr, struct inode *inode) { if (rr->u.SP.magic[0] != 0xbe) return -1; if (rr->u.SP.magic[1] != 0xef) return -1; ISOFS_SB(inode->i_sb)->s_rock_offset = rr->u.SP.skip; return 0; } |
76ab07ebc [PATCH] rock: rem... |
49 |
static void setup_rock_ridge(struct iso_directory_record *de, |
ba40aaf04 [PATCH] rock: rem... |
50 |
struct inode *inode, struct rock_state *rs) |
76ab07ebc [PATCH] rock: rem... |
51 |
{ |
ba40aaf04 [PATCH] rock: rem... |
52 53 54 55 56 57 58 |
rs->len = sizeof(struct iso_directory_record) + de->name_len[0]; if (rs->len & 1) (rs->len)++; rs->chr = (unsigned char *)de + rs->len; rs->len = *((unsigned char *)de) - rs->len; if (rs->len < 0) rs->len = 0; |
76ab07ebc [PATCH] rock: rem... |
59 60 |
if (ISOFS_SB(inode->i_sb)->s_rock_offset != -1) { |
ba40aaf04 [PATCH] rock: rem... |
61 62 63 64 |
rs->len -= ISOFS_SB(inode->i_sb)->s_rock_offset; rs->chr += ISOFS_SB(inode->i_sb)->s_rock_offset; if (rs->len < 0) rs->len = 0; |
76ab07ebc [PATCH] rock: rem... |
65 |
} |
1d3721163 [PATCH] rock: lin... |
66 |
} |
1da177e4c Linux-2.6.12-rc2 |
67 |
|
ba40aaf04 [PATCH] rock: rem... |
68 69 70 71 72 |
static void init_rock_state(struct rock_state *rs, struct inode *inode) { memset(rs, 0, sizeof(*rs)); rs->inode = inode; } |
f54e18f1b isofs: Fix infini... |
73 74 |
/* Maximum number of Rock Ridge continuation entries */ #define RR_MAX_CE_ENTRIES 32 |
ba40aaf04 [PATCH] rock: rem... |
75 76 77 78 79 80 81 |
/* * Returns 0 if the caller should continue scanning, 1 if the scan must end * and -ve on error. */ static int rock_continue(struct rock_state *rs) { int ret = 1; |
e595447e1 [PATCH] rock.c: h... |
82 83 |
int blocksize = 1 << rs->inode->i_blkbits; const int min_de_size = offsetof(struct rock_ridge, u); |
ba40aaf04 [PATCH] rock: rem... |
84 85 86 |
kfree(rs->buffer); rs->buffer = NULL; |
e595447e1 [PATCH] rock.c: h... |
87 88 89 90 91 92 93 94 95 96 97 |
if ((unsigned)rs->cont_offset > blocksize - min_de_size || (unsigned)rs->cont_size > blocksize || (unsigned)(rs->cont_offset + rs->cont_size) > blocksize) { printk(KERN_NOTICE "rock: corrupted directory entry. " "extent=%d, offset=%d, size=%d ", rs->cont_extent, rs->cont_offset, rs->cont_size); ret = -EIO; goto out; } |
ba40aaf04 [PATCH] rock: rem... |
98 99 100 101 102 103 104 105 106 |
if (rs->cont_extent) { struct buffer_head *bh; rs->buffer = kmalloc(rs->cont_size, GFP_KERNEL); if (!rs->buffer) { ret = -ENOMEM; goto out; } ret = -EIO; |
f54e18f1b isofs: Fix infini... |
107 108 |
if (++rs->cont_loops >= RR_MAX_CE_ENTRIES) goto out; |
ba40aaf04 [PATCH] rock: rem... |
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
bh = sb_bread(rs->inode->i_sb, rs->cont_extent); if (bh) { memcpy(rs->buffer, bh->b_data + rs->cont_offset, rs->cont_size); put_bh(bh); rs->chr = rs->buffer; rs->len = rs->cont_size; rs->cont_extent = 0; rs->cont_size = 0; rs->cont_offset = 0; return 0; } printk("Unable to read rock-ridge attributes "); } out: kfree(rs->buffer); rs->buffer = NULL; return ret; } |
1da177e4c Linux-2.6.12-rc2 |
129 |
|
7373909de [PATCH] rock: com... |
130 |
/* |
f2966632a [PATCH] rock: han... |
131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
* We think there's a record of type `sig' at rs->chr. Parse the signature * and make sure that there's really room for a record of that type. */ static int rock_check_overflow(struct rock_state *rs, int sig) { int len; switch (sig) { case SIG('S', 'P'): len = sizeof(struct SU_SP_s); break; case SIG('C', 'E'): len = sizeof(struct SU_CE_s); break; case SIG('E', 'R'): len = sizeof(struct SU_ER_s); break; case SIG('R', 'R'): len = sizeof(struct RR_RR_s); break; case SIG('P', 'X'): len = sizeof(struct RR_PX_s); break; case SIG('P', 'N'): len = sizeof(struct RR_PN_s); break; case SIG('S', 'L'): len = sizeof(struct RR_SL_s); break; case SIG('N', 'M'): len = sizeof(struct RR_NM_s); break; case SIG('C', 'L'): len = sizeof(struct RR_CL_s); break; case SIG('P', 'L'): len = sizeof(struct RR_PL_s); break; case SIG('T', 'F'): len = sizeof(struct RR_TF_s); break; case SIG('Z', 'F'): len = sizeof(struct RR_ZF_s); break; default: len = 0; break; } len += offsetof(struct rock_ridge, u); if (len > rs->len) { printk(KERN_NOTICE "rock: directory entry would overflow " "storage "); printk(KERN_NOTICE "rock: sig=0x%02x, size=%d, remaining=%d ", sig, len, rs->len); return -EIO; } return 0; } /* |
7373909de [PATCH] rock: com... |
193 194 |
* return length of name field; 0: not found, -1: to be ignored */ |
1d3721163 [PATCH] rock: lin... |
195 196 |
int get_rock_ridge_filename(struct iso_directory_record *de, char *retname, struct inode *inode) |
1da177e4c Linux-2.6.12-rc2 |
197 |
{ |
ba40aaf04 [PATCH] rock: rem... |
198 |
struct rock_state rs; |
7fa393a1d [PATCH] rock: man... |
199 200 201 202 |
struct rock_ridge *rr; int sig; int retnamlen = 0; int truncate = 0; |
ba40aaf04 [PATCH] rock: rem... |
203 |
int ret = 0; |
99d825822 get_rock_ridge_fi... |
204 205 |
char *p; int len; |
1da177e4c Linux-2.6.12-rc2 |
206 |
|
1d3721163 [PATCH] rock: lin... |
207 208 209 |
if (!ISOFS_SB(inode->i_sb)->s_rock) return 0; *retname = 0; |
ba40aaf04 [PATCH] rock: rem... |
210 211 |
init_rock_state(&rs, inode); setup_rock_ridge(de, inode, &rs); |
7fa393a1d [PATCH] rock: man... |
212 |
repeat: |
ba40aaf04 [PATCH] rock: rem... |
213 214 |
while (rs.len > 2) { /* There may be one byte for padding somewhere */ rr = (struct rock_ridge *)rs.chr; |
c0a1633b6 isofs: fix minor ... |
215 216 217 218 219 |
/* * Ignore rock ridge info if rr->len is out of range, but * don't return -EIO because that would make the file * invisible. */ |
7fa393a1d [PATCH] rock: man... |
220 221 |
if (rr->len < 3) goto out; /* Something got screwed up here */ |
ba40aaf04 [PATCH] rock: rem... |
222 |
sig = isonum_721(rs.chr); |
f2966632a [PATCH] rock: han... |
223 224 |
if (rock_check_overflow(&rs, sig)) goto eio; |
ba40aaf04 [PATCH] rock: rem... |
225 226 |
rs.chr += rr->len; rs.len -= rr->len; |
c0a1633b6 isofs: fix minor ... |
227 228 229 230 |
/* * As above, just ignore the rock ridge info if rr->len * is bogus. */ |
ba40aaf04 [PATCH] rock: rem... |
231 |
if (rs.len < 0) |
c0a1633b6 isofs: fix minor ... |
232 |
goto out; /* Something got screwed up here */ |
7fa393a1d [PATCH] rock: man... |
233 234 235 236 237 238 239 |
switch (sig) { case SIG('R', 'R'): if ((rr->u.RR.flags[0] & RR_NM) == 0) goto out; break; case SIG('S', 'P'): |
12121714f [PATCH] rock: rem... |
240 241 |
if (check_sp(rr, inode)) goto out; |
7fa393a1d [PATCH] rock: man... |
242 243 |
break; case SIG('C', 'E'): |
ba40aaf04 [PATCH] rock: rem... |
244 245 246 |
rs.cont_extent = isonum_733(rr->u.CE.extent); rs.cont_offset = isonum_733(rr->u.CE.offset); rs.cont_size = isonum_733(rr->u.CE.size); |
7fa393a1d [PATCH] rock: man... |
247 248 249 |
break; case SIG('N', 'M'): if (truncate) |
1d3721163 [PATCH] rock: lin... |
250 |
break; |
7fa393a1d [PATCH] rock: man... |
251 |
if (rr->len < 5) |
1d3721163 [PATCH] rock: lin... |
252 |
break; |
7fa393a1d [PATCH] rock: man... |
253 254 255 256 257 258 259 260 |
/* * If the flags are 2 or 4, this indicates '.' or '..'. * We don't want to do anything with this, because it * screws up the code that calls us. We don't really * care anyways, since we can just use the non-RR * name. */ if (rr->u.NM.flags & 6) |
1d3721163 [PATCH] rock: lin... |
261 |
break; |
1d3721163 [PATCH] rock: lin... |
262 |
|
7fa393a1d [PATCH] rock: man... |
263 264 265 266 |
if (rr->u.NM.flags & ~1) { printk("Unsupported NM flag settings (%d) ", rr->u.NM.flags); |
1d3721163 [PATCH] rock: lin... |
267 |
break; |
7fa393a1d [PATCH] rock: man... |
268 |
} |
99d825822 get_rock_ridge_fi... |
269 270 |
len = rr->len - 5; if (retnamlen + len >= 254) { |
7fa393a1d [PATCH] rock: man... |
271 |
truncate = 1; |
1d3721163 [PATCH] rock: lin... |
272 273 |
break; } |
99d825822 get_rock_ridge_fi... |
274 275 276 277 278 279 |
p = memchr(rr->u.NM.name, '\0', len); if (unlikely(p)) len = p - rr->u.NM.name; memcpy(retname + retnamlen, rr->u.NM.name, len); retnamlen += len; retname[retnamlen] = '\0'; |
7fa393a1d [PATCH] rock: man... |
280 281 |
break; case SIG('R', 'E'): |
ba40aaf04 [PATCH] rock: rem... |
282 |
kfree(rs.buffer); |
7fa393a1d [PATCH] rock: man... |
283 284 285 |
return -1; default: break; |
1d3721163 [PATCH] rock: lin... |
286 |
} |
1da177e4c Linux-2.6.12-rc2 |
287 |
} |
ba40aaf04 [PATCH] rock: rem... |
288 289 290 291 292 |
ret = rock_continue(&rs); if (ret == 0) goto repeat; if (ret == 1) return retnamlen; /* If 0, this file did not have a NM field */ |
7fa393a1d [PATCH] rock: man... |
293 |
out: |
ba40aaf04 [PATCH] rock: rem... |
294 295 |
kfree(rs.buffer); return ret; |
f2966632a [PATCH] rock: han... |
296 297 298 |
eio: ret = -EIO; goto out; |
1da177e4c Linux-2.6.12-rc2 |
299 |
} |
410dd3cf4 isofs: Fix unboun... |
300 301 |
#define RR_REGARD_XA 1 #define RR_RELOC_DE 2 |
1da177e4c Linux-2.6.12-rc2 |
302 303 |
static int parse_rock_ridge_inode_internal(struct iso_directory_record *de, |
410dd3cf4 isofs: Fix unboun... |
304 |
struct inode *inode, int flags) |
1da177e4c Linux-2.6.12-rc2 |
305 |
{ |
1d3721163 [PATCH] rock: lin... |
306 |
int symlink_len = 0; |
7fa393a1d [PATCH] rock: man... |
307 |
int cnt, sig; |
410dd3cf4 isofs: Fix unboun... |
308 |
unsigned int reloc_block; |
7fa393a1d [PATCH] rock: man... |
309 310 311 |
struct inode *reloc; struct rock_ridge *rr; int rootflag; |
ba40aaf04 [PATCH] rock: rem... |
312 313 |
struct rock_state rs; int ret = 0; |
1d3721163 [PATCH] rock: lin... |
314 315 316 |
if (!ISOFS_SB(inode->i_sb)->s_rock) return 0; |
ba40aaf04 [PATCH] rock: rem... |
317 318 |
init_rock_state(&rs, inode); setup_rock_ridge(de, inode, &rs); |
410dd3cf4 isofs: Fix unboun... |
319 |
if (flags & RR_REGARD_XA) { |
ba40aaf04 [PATCH] rock: rem... |
320 321 322 323 |
rs.chr += 14; rs.len -= 14; if (rs.len < 0) rs.len = 0; |
1d3721163 [PATCH] rock: lin... |
324 |
} |
7fa393a1d [PATCH] rock: man... |
325 |
repeat: |
ba40aaf04 [PATCH] rock: rem... |
326 327 |
while (rs.len > 2) { /* There may be one byte for padding somewhere */ rr = (struct rock_ridge *)rs.chr; |
c0a1633b6 isofs: fix minor ... |
328 329 330 331 332 |
/* * Ignore rock ridge info if rr->len is out of range, but * don't return -EIO because that would make the file * invisible. */ |
7fa393a1d [PATCH] rock: man... |
333 334 |
if (rr->len < 3) goto out; /* Something got screwed up here */ |
ba40aaf04 [PATCH] rock: rem... |
335 |
sig = isonum_721(rs.chr); |
f2966632a [PATCH] rock: han... |
336 337 |
if (rock_check_overflow(&rs, sig)) goto eio; |
ba40aaf04 [PATCH] rock: rem... |
338 339 |
rs.chr += rr->len; rs.len -= rr->len; |
c0a1633b6 isofs: fix minor ... |
340 341 342 343 |
/* * As above, just ignore the rock ridge info if rr->len * is bogus. */ |
ba40aaf04 [PATCH] rock: rem... |
344 |
if (rs.len < 0) |
c0a1633b6 isofs: fix minor ... |
345 |
goto out; /* Something got screwed up here */ |
7fa393a1d [PATCH] rock: man... |
346 347 |
switch (sig) { |
1da177e4c Linux-2.6.12-rc2 |
348 |
#ifndef CONFIG_ZISOFS /* No flag for SF or ZF */ |
7fa393a1d [PATCH] rock: man... |
349 350 351 352 353 |
case SIG('R', 'R'): if ((rr->u.RR.flags[0] & (RR_PX | RR_TF | RR_SL | RR_CL)) == 0) goto out; break; |
1da177e4c Linux-2.6.12-rc2 |
354 |
#endif |
7fa393a1d [PATCH] rock: man... |
355 |
case SIG('S', 'P'): |
12121714f [PATCH] rock: rem... |
356 357 |
if (check_sp(rr, inode)) goto out; |
7fa393a1d [PATCH] rock: man... |
358 359 |
break; case SIG('C', 'E'): |
ba40aaf04 [PATCH] rock: rem... |
360 361 362 |
rs.cont_extent = isonum_733(rr->u.CE.extent); rs.cont_offset = isonum_733(rr->u.CE.offset); rs.cont_size = isonum_733(rr->u.CE.size); |
7fa393a1d [PATCH] rock: man... |
363 364 |
break; case SIG('E', 'R'): |
4e2024624 isofs: Fix unchec... |
365 366 367 |
/* Invalid length of ER tag id? */ if (rr->u.ER.len_id + offsetof(struct rock_ridge, u.ER.data) > rr->len) goto out; |
7fa393a1d [PATCH] rock: man... |
368 369 370 371 372 |
ISOFS_SB(inode->i_sb)->s_rock = 1; printk(KERN_DEBUG "ISO 9660 Extensions: "); { int p; for (p = 0; p < rr->u.ER.len_id; p++) |
a107bf8b3 isofs: add KERN_C... |
373 |
printk(KERN_CONT "%c", rr->u.ER.data[p]); |
7fa393a1d [PATCH] rock: man... |
374 |
} |
a107bf8b3 isofs: add KERN_C... |
375 376 |
printk(KERN_CONT " "); |
7fa393a1d [PATCH] rock: man... |
377 378 379 |
break; case SIG('P', 'X'): inode->i_mode = isonum_733(rr->u.PX.mode); |
bfe868486 filesystems: add ... |
380 |
set_nlink(inode, isonum_733(rr->u.PX.n_links)); |
ba64e2b9e userns: Convert i... |
381 382 |
i_uid_write(inode, isonum_733(rr->u.PX.uid)); i_gid_write(inode, isonum_733(rr->u.PX.gid)); |
7fa393a1d [PATCH] rock: man... |
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
break; case SIG('P', 'N'): { int high, low; high = isonum_733(rr->u.PN.dev_high); low = isonum_733(rr->u.PN.dev_low); /* * The Rock Ridge standard specifies that if * sizeof(dev_t) <= 4, then the high field is * unused, and the device number is completely * stored in the low field. Some writers may * ignore this subtlety, * and as a result we test to see if the entire * device number is * stored in the low field, and use that. */ if ((low & ~0xff) && high == 0) { inode->i_rdev = MKDEV(low >> 8, low & 0xff); } else { inode->i_rdev = MKDEV(high, low); |
1d3721163 [PATCH] rock: lin... |
405 |
} |
7fa393a1d [PATCH] rock: man... |
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
} break; case SIG('T', 'F'): /* * Some RRIP writers incorrectly place ctime in the * TF_CREATE field. Try to handle this correctly for * either case. */ /* Rock ridge never appears on a High Sierra disk */ cnt = 0; if (rr->u.TF.flags & TF_CREATE) { inode->i_ctime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0); inode->i_ctime.tv_nsec = 0; } if (rr->u.TF.flags & TF_MODIFY) { inode->i_mtime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0); inode->i_mtime.tv_nsec = 0; } if (rr->u.TF.flags & TF_ACCESS) { inode->i_atime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0); inode->i_atime.tv_nsec = 0; } if (rr->u.TF.flags & TF_ATTRIBUTES) { inode->i_ctime.tv_sec = iso_date(rr->u.TF.times[cnt++].time, 0); inode->i_ctime.tv_nsec = 0; } break; case SIG('S', 'L'): { int slen; struct SL_component *slp; struct SL_component *oldslp; slen = rr->len - 5; slp = &rr->u.SL.link; inode->i_size = symlink_len; while (slen > 1) { rootflag = 0; switch (slp->flags & ~1) { case 0: inode->i_size += slp->len; break; case 2: inode->i_size += 1; break; case 4: inode->i_size += 2; break; case 8: rootflag = 1; inode->i_size += 1; break; default: printk("Symlink component flag " "not implemented "); |
1d3721163 [PATCH] rock: lin... |
470 |
} |
7fa393a1d [PATCH] rock: man... |
471 472 473 474 475 476 477 478 479 480 481 |
slen -= slp->len + 2; oldslp = slp; slp = (struct SL_component *) (((char *)slp) + slp->len + 2); if (slen < 2) { if (((rr->u.SL. flags & 1) != 0) && ((oldslp-> flags & 1) == 0)) |
1d3721163 [PATCH] rock: lin... |
482 |
inode->i_size += |
7fa393a1d [PATCH] rock: man... |
483 484 |
1; break; |
1d3721163 [PATCH] rock: lin... |
485 |
} |
7fa393a1d [PATCH] rock: man... |
486 487 488 489 490 491 492 493 |
/* * If this component record isn't * continued, then append a '/'. */ if (!rootflag && (oldslp->flags & 1) == 0) inode->i_size += 1; |
1d3721163 [PATCH] rock: lin... |
494 |
} |
7fa393a1d [PATCH] rock: man... |
495 496 497 498 499 500 501 502 503 |
} symlink_len = inode->i_size; break; case SIG('R', 'E'): printk(KERN_WARNING "Attempt to read inode for " "relocated directory "); goto out; case SIG('C', 'L'): |
410dd3cf4 isofs: Fix unboun... |
504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
if (flags & RR_RELOC_DE) { printk(KERN_ERR "ISOFS: Recursive directory relocation " "is not supported "); goto eio; } reloc_block = isonum_733(rr->u.CL.location); if (reloc_block == ISOFS_I(inode)->i_iget5_block && ISOFS_I(inode)->i_iget5_offset == 0) { printk(KERN_ERR "ISOFS: Directory relocation points to " "itself "); goto eio; } ISOFS_I(inode)->i_first_extent = reloc_block; reloc = isofs_iget_reloc(inode->i_sb, reloc_block, 0); |
c4386c83b iget: stop ISOFS ... |
522 523 |
if (IS_ERR(reloc)) { ret = PTR_ERR(reloc); |
1d3721163 [PATCH] rock: lin... |
524 |
goto out; |
c4386c83b iget: stop ISOFS ... |
525 |
} |
7fa393a1d [PATCH] rock: man... |
526 |
inode->i_mode = reloc->i_mode; |
bfe868486 filesystems: add ... |
527 |
set_nlink(inode, reloc->i_nlink); |
7fa393a1d [PATCH] rock: man... |
528 529 530 531 532 533 534 535 536 537 |
inode->i_uid = reloc->i_uid; inode->i_gid = reloc->i_gid; inode->i_rdev = reloc->i_rdev; inode->i_size = reloc->i_size; inode->i_blocks = reloc->i_blocks; inode->i_atime = reloc->i_atime; inode->i_ctime = reloc->i_ctime; inode->i_mtime = reloc->i_mtime; iput(reloc); break; |
1da177e4c Linux-2.6.12-rc2 |
538 |
#ifdef CONFIG_ZISOFS |
7fa393a1d [PATCH] rock: man... |
539 540 541 542 |
case SIG('Z', 'F'): { int algo; if (ISOFS_SB(inode->i_sb)->s_nocompress) |
1d3721163 [PATCH] rock: lin... |
543 |
break; |
7fa393a1d [PATCH] rock: man... |
544 545 546 547 |
algo = isonum_721(rr->u.ZF.algorithm); if (algo == SIG('p', 'z')) { int block_shift = isonum_711(&rr->u.ZF.parms[1]); |
59bc05521 zisofs: Implement... |
548 |
if (block_shift > 17) { |
7fa393a1d [PATCH] rock: man... |
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
printk(KERN_WARNING "isofs: " "Can't handle ZF block " "size of 2^%d ", block_shift); } else { /* * Note: we don't change * i_blocks here */ ISOFS_I(inode)->i_file_format = isofs_file_compressed; /* * Parameters to compression * algorithm (header size, * block size) */ ISOFS_I(inode)->i_format_parm[0] = isonum_711(&rr->u.ZF.parms[0]); ISOFS_I(inode)->i_format_parm[1] = isonum_711(&rr->u.ZF.parms[1]); inode->i_size = isonum_733(rr->u.ZF. real_size); } } else { printk(KERN_WARNING "isofs: Unknown ZF compression " "algorithm: %c%c ", rr->u.ZF.algorithm[0], rr->u.ZF.algorithm[1]); |
1d3721163 [PATCH] rock: lin... |
581 |
} |
7fa393a1d [PATCH] rock: man... |
582 583 584 585 586 |
break; } #endif default: break; |
1d3721163 [PATCH] rock: lin... |
587 588 |
} } |
ba40aaf04 [PATCH] rock: rem... |
589 590 591 592 593 |
ret = rock_continue(&rs); if (ret == 0) goto repeat; if (ret == 1) ret = 0; |
7fa393a1d [PATCH] rock: man... |
594 |
out: |
ba40aaf04 [PATCH] rock: rem... |
595 596 |
kfree(rs.buffer); return ret; |
f2966632a [PATCH] rock: han... |
597 598 599 |
eio: ret = -EIO; goto out; |
1da177e4c Linux-2.6.12-rc2 |
600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
} static char *get_symlink_chunk(char *rpnt, struct rock_ridge *rr, char *plimit) { int slen; int rootflag; struct SL_component *oldslp; struct SL_component *slp; slen = rr->len - 5; slp = &rr->u.SL.link; while (slen > 1) { rootflag = 0; switch (slp->flags & ~1) { case 0: if (slp->len > plimit - rpnt) return NULL; memcpy(rpnt, slp->text, slp->len); |
1d3721163 [PATCH] rock: lin... |
617 |
rpnt += slp->len; |
1da177e4c Linux-2.6.12-rc2 |
618 619 620 621 |
break; case 2: if (rpnt >= plimit) return NULL; |
1d3721163 [PATCH] rock: lin... |
622 |
*rpnt++ = '.'; |
1da177e4c Linux-2.6.12-rc2 |
623 624 625 626 |
break; case 4: if (2 > plimit - rpnt) return NULL; |
1d3721163 [PATCH] rock: lin... |
627 628 |
*rpnt++ = '.'; *rpnt++ = '.'; |
1da177e4c Linux-2.6.12-rc2 |
629 630 631 632 633 |
break; case 8: if (rpnt >= plimit) return NULL; rootflag = 1; |
1d3721163 [PATCH] rock: lin... |
634 |
*rpnt++ = '/'; |
1da177e4c Linux-2.6.12-rc2 |
635 636 637 638 |
break; default: printk("Symlink component flag not implemented (%d) ", |
1d3721163 [PATCH] rock: lin... |
639 |
slp->flags); |
1da177e4c Linux-2.6.12-rc2 |
640 641 642 |
} slen -= slp->len + 2; oldslp = slp; |
1d3721163 [PATCH] rock: lin... |
643 |
slp = (struct SL_component *)((char *)slp + slp->len + 2); |
1da177e4c Linux-2.6.12-rc2 |
644 645 646 647 648 649 650 651 652 653 |
if (slen < 2) { /* * If there is another SL record, and this component * record isn't continued, then add a slash. */ if ((!rootflag) && (rr->u.SL.flags & 1) && !(oldslp->flags & 1)) { if (rpnt >= plimit) return NULL; |
1d3721163 [PATCH] rock: lin... |
654 |
*rpnt++ = '/'; |
1da177e4c Linux-2.6.12-rc2 |
655 656 657 658 659 660 661 662 663 664 |
} break; } /* * If this component record isn't continued, then append a '/'. */ if (!rootflag && !(oldslp->flags & 1)) { if (rpnt >= plimit) return NULL; |
1d3721163 [PATCH] rock: lin... |
665 |
*rpnt++ = '/'; |
1da177e4c Linux-2.6.12-rc2 |
666 667 668 669 |
} } return rpnt; } |
410dd3cf4 isofs: Fix unboun... |
670 671 |
int parse_rock_ridge_inode(struct iso_directory_record *de, struct inode *inode, int relocated) |
1da177e4c Linux-2.6.12-rc2 |
672 |
{ |
410dd3cf4 isofs: Fix unboun... |
673 674 |
int flags = relocated ? RR_RELOC_DE : 0; int result = parse_rock_ridge_inode_internal(de, inode, flags); |
7373909de [PATCH] rock: com... |
675 676 677 678 679 |
/* * if rockridge flag was reset and we didn't look for attributes * behind eventual XA attributes, have a look there */ |
1d3721163 [PATCH] rock: lin... |
680 681 |
if ((ISOFS_SB(inode->i_sb)->s_rock_offset == -1) && (ISOFS_SB(inode->i_sb)->s_rock == 2)) { |
410dd3cf4 isofs: Fix unboun... |
682 683 |
result = parse_rock_ridge_inode_internal(de, inode, flags | RR_REGARD_XA); |
1d3721163 [PATCH] rock: lin... |
684 685 |
} return result; |
1da177e4c Linux-2.6.12-rc2 |
686 |
} |
7373909de [PATCH] rock: com... |
687 688 689 690 |
/* * readpage() for symlinks: reads symlink contents into the page and either * makes it uptodate and returns 0 or returns error (-EIO) */ |
1da177e4c Linux-2.6.12-rc2 |
691 692 693 |
static int rock_ridge_symlink_readpage(struct file *file, struct page *page) { struct inode *inode = page->mapping->host; |
1d3721163 [PATCH] rock: lin... |
694 |
struct iso_inode_info *ei = ISOFS_I(inode); |
4f819a789 BKL: Remove BKL f... |
695 |
struct isofs_sb_info *sbi = ISOFS_SB(inode->i_sb); |
21fc61c73 don't put symlink... |
696 |
char *link = page_address(page); |
1da177e4c Linux-2.6.12-rc2 |
697 698 699 700 |
unsigned long bufsize = ISOFS_BUFFER_SIZE(inode); struct buffer_head *bh; char *rpnt = link; unsigned char *pnt; |
76ab07ebc [PATCH] rock: rem... |
701 |
struct iso_directory_record *raw_de; |
1da177e4c Linux-2.6.12-rc2 |
702 703 |
unsigned long block, offset; int sig; |
1da177e4c Linux-2.6.12-rc2 |
704 |
struct rock_ridge *rr; |
ba40aaf04 [PATCH] rock: rem... |
705 706 |
struct rock_state rs; int ret; |
1da177e4c Linux-2.6.12-rc2 |
707 |
|
4f819a789 BKL: Remove BKL f... |
708 |
if (!sbi->s_rock) |
1da177e4c Linux-2.6.12-rc2 |
709 |
goto error; |
ba40aaf04 [PATCH] rock: rem... |
710 |
init_rock_state(&rs, inode); |
1da177e4c Linux-2.6.12-rc2 |
711 |
block = ei->i_iget5_block; |
1da177e4c Linux-2.6.12-rc2 |
712 713 714 |
bh = sb_bread(inode->i_sb, block); if (!bh) goto out_noread; |
1d3721163 [PATCH] rock: lin... |
715 716 |
offset = ei->i_iget5_offset; pnt = (unsigned char *)bh->b_data + offset; |
1da177e4c Linux-2.6.12-rc2 |
717 |
|
76ab07ebc [PATCH] rock: rem... |
718 |
raw_de = (struct iso_directory_record *)pnt; |
1da177e4c Linux-2.6.12-rc2 |
719 720 721 722 723 724 |
/* * If we go past the end of the buffer, there is some sort of error. */ if (offset + *pnt > bufsize) goto out_bad_span; |
7373909de [PATCH] rock: com... |
725 726 727 728 |
/* * Now test for possible Rock Ridge extensions which will override * some of these numbers in the inode structure. */ |
1da177e4c Linux-2.6.12-rc2 |
729 |
|
ba40aaf04 [PATCH] rock: rem... |
730 |
setup_rock_ridge(raw_de, inode, &rs); |
1da177e4c Linux-2.6.12-rc2 |
731 |
|
7fa393a1d [PATCH] rock: man... |
732 |
repeat: |
ba40aaf04 [PATCH] rock: rem... |
733 734 |
while (rs.len > 2) { /* There may be one byte for padding somewhere */ rr = (struct rock_ridge *)rs.chr; |
1da177e4c Linux-2.6.12-rc2 |
735 736 |
if (rr->len < 3) goto out; /* Something got screwed up here */ |
ba40aaf04 [PATCH] rock: rem... |
737 |
sig = isonum_721(rs.chr); |
f2966632a [PATCH] rock: han... |
738 739 |
if (rock_check_overflow(&rs, sig)) goto out; |
ba40aaf04 [PATCH] rock: rem... |
740 741 742 |
rs.chr += rr->len; rs.len -= rr->len; if (rs.len < 0) |
1da177e4c Linux-2.6.12-rc2 |
743 744 745 746 747 748 749 750 |
goto out; /* corrupted isofs */ switch (sig) { case SIG('R', 'R'): if ((rr->u.RR.flags[0] & RR_SL) == 0) goto out; break; case SIG('S', 'P'): |
12121714f [PATCH] rock: rem... |
751 752 |
if (check_sp(rr, inode)) goto out; |
1da177e4c Linux-2.6.12-rc2 |
753 754 755 756 757 758 759 760 761 |
break; case SIG('S', 'L'): rpnt = get_symlink_chunk(rpnt, rr, link + (PAGE_SIZE - 1)); if (rpnt == NULL) goto out; break; case SIG('C', 'E'): /* This tells is if there is a continuation record */ |
ba40aaf04 [PATCH] rock: rem... |
762 763 764 |
rs.cont_extent = isonum_733(rr->u.CE.extent); rs.cont_offset = isonum_733(rr->u.CE.offset); rs.cont_size = isonum_733(rr->u.CE.size); |
1da177e4c Linux-2.6.12-rc2 |
765 766 767 768 |
default: break; } } |
ba40aaf04 [PATCH] rock: rem... |
769 770 771 772 773 |
ret = rock_continue(&rs); if (ret == 0) goto repeat; if (ret < 0) goto fail; |
1da177e4c Linux-2.6.12-rc2 |
774 775 776 777 778 |
if (rpnt == link) goto fail; brelse(bh); *rpnt = '\0'; |
1da177e4c Linux-2.6.12-rc2 |
779 |
SetPageUptodate(page); |
1da177e4c Linux-2.6.12-rc2 |
780 781 782 783 |
unlock_page(page); return 0; /* error exit from macro */ |
7fa393a1d [PATCH] rock: man... |
784 |
out: |
ba40aaf04 [PATCH] rock: rem... |
785 |
kfree(rs.buffer); |
1da177e4c Linux-2.6.12-rc2 |
786 |
goto fail; |
7fa393a1d [PATCH] rock: man... |
787 |
out_noread: |
1da177e4c Linux-2.6.12-rc2 |
788 789 |
printk("unable to read i-node block"); goto fail; |
7fa393a1d [PATCH] rock: man... |
790 |
out_bad_span: |
1da177e4c Linux-2.6.12-rc2 |
791 792 |
printk("symlink spans iso9660 blocks "); |
7fa393a1d [PATCH] rock: man... |
793 |
fail: |
1da177e4c Linux-2.6.12-rc2 |
794 |
brelse(bh); |
7fa393a1d [PATCH] rock: man... |
795 |
error: |
1da177e4c Linux-2.6.12-rc2 |
796 |
SetPageError(page); |
1da177e4c Linux-2.6.12-rc2 |
797 798 799 |
unlock_page(page); return -EIO; } |
f5e54d6e5 [PATCH] mark addr... |
800 |
const struct address_space_operations isofs_symlink_aops = { |
1d3721163 [PATCH] rock: lin... |
801 |
.readpage = rock_ridge_symlink_readpage |
1da177e4c Linux-2.6.12-rc2 |
802 |
}; |