Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * directory.c |
| 3 | * |
| 4 | * PURPOSE |
| 5 | * Directory related functions |
| 6 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * COPYRIGHT |
| 8 | * This file is distributed under the terms of the GNU General Public |
| 9 | * License (GPL). Copies of the GPL can be obtained from: |
| 10 | * ftp://prep.ai.mit.edu/pub/gnu/GPL |
| 11 | * Each contributing author retains all rights to their own work. |
| 12 | */ |
| 13 | |
| 14 | #include "udfdecl.h" |
| 15 | #include "udf_i.h" |
| 16 | |
| 17 | #include <linux/fs.h> |
| 18 | #include <linux/string.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 20 | struct fileIdentDesc *udf_fileident_read(struct inode *dir, loff_t *nf_pos, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 21 | struct udf_fileident_bh *fibh, |
| 22 | struct fileIdentDesc *cfi, |
| 23 | struct extent_position *epos, |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 24 | struct kernel_lb_addr *eloc, uint32_t *elen, |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 25 | sector_t *offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | { |
| 27 | struct fileIdentDesc *fi; |
| 28 | int i, num, block; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 29 | struct buffer_head *tmp, *bha[16]; |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 30 | struct udf_inode_info *iinfo = UDF_I(dir); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
| 32 | fibh->soffset = fibh->eoffset; |
| 33 | |
Marcin Slusarz | 48d6d8f | 2008-02-08 04:20:44 -0800 | [diff] [blame] | 34 | if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_IN_ICB) { |
| 35 | fi = udf_get_fileident(iinfo->i_ext.i_data - |
| 36 | (iinfo->i_efe ? |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 37 | sizeof(struct extendedFileEntry) : |
| 38 | sizeof(struct fileEntry)), |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 39 | dir->i_sb->s_blocksize, |
| 40 | &(fibh->eoffset)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | if (!fi) |
| 42 | return NULL; |
| 43 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 44 | *nf_pos += fibh->eoffset - fibh->soffset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 46 | memcpy((uint8_t *)cfi, (uint8_t *)fi, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 47 | sizeof(struct fileIdentDesc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | return fi; |
| 50 | } |
| 51 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 52 | if (fibh->eoffset == dir->i_sb->s_blocksize) { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 53 | int lextoffset = epos->offset; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 54 | unsigned char blocksize_bits = dir->i_sb->s_blocksize_bits; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 56 | if (udf_next_aext(dir, epos, eloc, elen, 1) != |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 57 | (EXT_RECORDED_ALLOCATED >> 30)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
Pekka Enberg | 97e961f | 2008-10-15 12:29:03 +0200 | [diff] [blame] | 60 | block = udf_get_lb_pblock(dir->i_sb, eloc, *offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 62 | (*offset)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 64 | if ((*offset << blocksize_bits) >= *elen) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | *offset = 0; |
| 66 | else |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 67 | epos->offset = lextoffset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 69 | brelse(fibh->sbh); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 70 | fibh->sbh = fibh->ebh = udf_tread(dir->i_sb, block); |
| 71 | if (!fibh->sbh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | return NULL; |
| 73 | fibh->soffset = fibh->eoffset = 0; |
| 74 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 75 | if (!(*offset & ((16 >> (blocksize_bits - 9)) - 1))) { |
| 76 | i = 16 >> (blocksize_bits - 9); |
| 77 | if (i + *offset > (*elen >> blocksize_bits)) |
| 78 | i = (*elen >> blocksize_bits)-*offset; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 79 | for (num = 0; i > 0; i--) { |
Pekka Enberg | 97e961f | 2008-10-15 12:29:03 +0200 | [diff] [blame] | 80 | block = udf_get_lb_pblock(dir->i_sb, eloc, |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 81 | *offset + i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | tmp = udf_tgetblk(dir->i_sb, block); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 83 | if (tmp && !buffer_uptodate(tmp) && |
| 84 | !buffer_locked(tmp)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | bha[num++] = tmp; |
| 86 | else |
| 87 | brelse(tmp); |
| 88 | } |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 89 | if (num) { |
Christoph Hellwig | 7024628 | 2016-07-19 11:28:41 +0200 | [diff] [blame] | 90 | ll_rw_block(REQ_OP_READ, REQ_RAHEAD, num, bha); |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 91 | for (i = 0; i < num; i++) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | brelse(bha[i]); |
| 93 | } |
| 94 | } |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 95 | } else if (fibh->sbh != fibh->ebh) { |
Jan Kara | 3bf25cb | 2007-05-08 00:35:16 -0700 | [diff] [blame] | 96 | brelse(fibh->sbh); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | fibh->sbh = fibh->ebh; |
| 98 | } |
| 99 | |
| 100 | fi = udf_get_fileident(fibh->sbh->b_data, dir->i_sb->s_blocksize, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 101 | &(fibh->eoffset)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | |
| 103 | if (!fi) |
| 104 | return NULL; |
| 105 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 106 | *nf_pos += fibh->eoffset - fibh->soffset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 108 | if (fibh->eoffset <= dir->i_sb->s_blocksize) { |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 109 | memcpy((uint8_t *)cfi, (uint8_t *)fi, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 110 | sizeof(struct fileIdentDesc)); |
| 111 | } else if (fibh->eoffset > dir->i_sb->s_blocksize) { |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 112 | int lextoffset = epos->offset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 114 | if (udf_next_aext(dir, epos, eloc, elen, 1) != |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 115 | (EXT_RECORDED_ALLOCATED >> 30)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | return NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Pekka Enberg | 97e961f | 2008-10-15 12:29:03 +0200 | [diff] [blame] | 118 | block = udf_get_lb_pblock(dir->i_sb, eloc, *offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 120 | (*offset)++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | |
| 122 | if ((*offset << dir->i_sb->s_blocksize_bits) >= *elen) |
| 123 | *offset = 0; |
| 124 | else |
Jan Kara | ff116fc | 2007-05-08 00:35:14 -0700 | [diff] [blame] | 125 | epos->offset = lextoffset; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | |
| 127 | fibh->soffset -= dir->i_sb->s_blocksize; |
| 128 | fibh->eoffset -= dir->i_sb->s_blocksize; |
| 129 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 130 | fibh->ebh = udf_tread(dir->i_sb, block); |
| 131 | if (!fibh->ebh) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | return NULL; |
| 133 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 134 | if (sizeof(struct fileIdentDesc) > -fibh->soffset) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | int fi_len; |
| 136 | |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 137 | memcpy((uint8_t *)cfi, (uint8_t *)fi, -fibh->soffset); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 138 | memcpy((uint8_t *)cfi - fibh->soffset, |
| 139 | fibh->ebh->b_data, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 140 | sizeof(struct fileIdentDesc) + fibh->soffset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 141 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 142 | fi_len = (sizeof(struct fileIdentDesc) + |
| 143 | cfi->lengthFileIdent + |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 144 | le16_to_cpu(cfi->lengthOfImpUse) + 3) & ~3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
Jan Kara | af79329 | 2008-02-08 04:20:50 -0800 | [diff] [blame] | 146 | *nf_pos += fi_len - (fibh->eoffset - fibh->soffset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | fibh->eoffset = fibh->soffset + fi_len; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 148 | } else { |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 149 | memcpy((uint8_t *)cfi, (uint8_t *)fi, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 150 | sizeof(struct fileIdentDesc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | } |
| 152 | } |
| 153 | return fi; |
| 154 | } |
| 155 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 156 | struct fileIdentDesc *udf_get_fileident(void *buffer, int bufsize, int *offset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | { |
| 158 | struct fileIdentDesc *fi; |
| 159 | int lengthThisIdent; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 160 | uint8_t *ptr; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | int padlen; |
| 162 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 163 | if ((!buffer) || (!offset)) { |
Joe Perches | a983f36 | 2011-10-10 01:08:07 -0700 | [diff] [blame] | 164 | udf_debug("invalidparms, buffer=%p, offset=%p\n", |
| 165 | buffer, offset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | return NULL; |
| 167 | } |
| 168 | |
| 169 | ptr = buffer; |
| 170 | |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 171 | if ((*offset > 0) && (*offset < bufsize)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 172 | ptr += *offset; |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 173 | fi = (struct fileIdentDesc *)ptr; |
Marcin Slusarz | 5e0f001 | 2008-02-08 04:20:41 -0800 | [diff] [blame] | 174 | if (fi->descTag.tagIdent != cpu_to_le16(TAG_IDENT_FID)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | udf_debug("0x%x != TAG_IDENT_FID\n", |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 176 | le16_to_cpu(fi->descTag.tagIdent)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 177 | udf_debug("offset: %u sizeof: %lu bufsize: %u\n", |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 178 | *offset, (unsigned long)sizeof(struct fileIdentDesc), |
| 179 | bufsize); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | return NULL; |
| 181 | } |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 182 | if ((*offset + sizeof(struct fileIdentDesc)) > bufsize) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | lengthThisIdent = sizeof(struct fileIdentDesc); |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 184 | else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | lengthThisIdent = sizeof(struct fileIdentDesc) + |
Cyrill Gorcunov | 28de794 | 2007-07-21 04:37:18 -0700 | [diff] [blame] | 186 | fi->lengthFileIdent + le16_to_cpu(fi->lengthOfImpUse); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | |
| 188 | /* we need to figure padding, too! */ |
| 189 | padlen = lengthThisIdent % UDF_NAME_PAD; |
| 190 | if (padlen) |
| 191 | lengthThisIdent += (UDF_NAME_PAD - padlen); |
| 192 | *offset = *offset + lengthThisIdent; |
| 193 | |
| 194 | return fi; |
| 195 | } |
| 196 | |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 197 | struct short_ad *udf_get_fileshortad(uint8_t *ptr, int maxoffset, uint32_t *offset, |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 198 | int inc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 199 | { |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 200 | struct short_ad *sa; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 201 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 202 | if ((!ptr) || (!offset)) { |
Joe Perches | 78ace70 | 2011-10-10 01:08:05 -0700 | [diff] [blame] | 203 | pr_err("%s: invalidparms\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | return NULL; |
| 205 | } |
| 206 | |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 207 | if ((*offset + sizeof(struct short_ad)) > maxoffset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | return NULL; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 209 | else { |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 210 | sa = (struct short_ad *)ptr; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 211 | if (sa->extLength == 0) |
| 212 | return NULL; |
| 213 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | |
| 215 | if (inc) |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 216 | *offset += sizeof(struct short_ad); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 217 | return sa; |
| 218 | } |
| 219 | |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 220 | struct long_ad *udf_get_filelongad(uint8_t *ptr, int maxoffset, uint32_t *offset, int inc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | { |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 222 | struct long_ad *la; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | |
Cyrill Gorcunov | cb00ea3 | 2007-07-19 01:47:43 -0700 | [diff] [blame] | 224 | if ((!ptr) || (!offset)) { |
Joe Perches | 78ace70 | 2011-10-10 01:08:05 -0700 | [diff] [blame] | 225 | pr_err("%s: invalidparms\n", __func__); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 | return NULL; |
| 227 | } |
| 228 | |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 229 | if ((*offset + sizeof(struct long_ad)) > maxoffset) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | return NULL; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 231 | else { |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 232 | la = (struct long_ad *)ptr; |
Marcin Slusarz | 4b11111 | 2008-02-08 04:20:36 -0800 | [diff] [blame] | 233 | if (la->extLength == 0) |
| 234 | return NULL; |
| 235 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | |
| 237 | if (inc) |
Pekka Enberg | 5ca4e4b | 2008-10-15 12:28:03 +0200 | [diff] [blame] | 238 | *offset += sizeof(struct long_ad); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | return la; |
| 240 | } |