diff options
Diffstat (limited to 'fs/udf/misc.c')
-rw-r--r-- | fs/udf/misc.c | 40 |
1 files changed, 21 insertions, 19 deletions
diff --git a/fs/udf/misc.c b/fs/udf/misc.c index 2af44702633b..a1d6da0caf71 100644 --- a/fs/udf/misc.c +++ b/fs/udf/misc.c | |||
@@ -51,17 +51,18 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
51 | uint8_t *ea = NULL, *ad = NULL; | 51 | uint8_t *ea = NULL, *ad = NULL; |
52 | int offset; | 52 | int offset; |
53 | uint16_t crclen; | 53 | uint16_t crclen; |
54 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
54 | 55 | ||
55 | ea = UDF_I(inode)->i_ext.i_data; | 56 | ea = iinfo->i_ext.i_data; |
56 | if (UDF_I(inode)->i_lenEAttr) { | 57 | if (iinfo->i_lenEAttr) { |
57 | ad = UDF_I(inode)->i_ext.i_data + UDF_I(inode)->i_lenEAttr; | 58 | ad = iinfo->i_ext.i_data + iinfo->i_lenEAttr; |
58 | } else { | 59 | } else { |
59 | ad = ea; | 60 | ad = ea; |
60 | size += sizeof(struct extendedAttrHeaderDesc); | 61 | size += sizeof(struct extendedAttrHeaderDesc); |
61 | } | 62 | } |
62 | 63 | ||
63 | offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) - | 64 | offset = inode->i_sb->s_blocksize - udf_file_entry_alloc_offset(inode) - |
64 | UDF_I(inode)->i_lenAlloc; | 65 | iinfo->i_lenAlloc; |
65 | 66 | ||
66 | /* TODO - Check for FreeEASpace */ | 67 | /* TODO - Check for FreeEASpace */ |
67 | 68 | ||
@@ -69,21 +70,21 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
69 | struct extendedAttrHeaderDesc *eahd; | 70 | struct extendedAttrHeaderDesc *eahd; |
70 | eahd = (struct extendedAttrHeaderDesc *)ea; | 71 | eahd = (struct extendedAttrHeaderDesc *)ea; |
71 | 72 | ||
72 | if (UDF_I(inode)->i_lenAlloc) | 73 | if (iinfo->i_lenAlloc) |
73 | memmove(&ad[size], ad, UDF_I(inode)->i_lenAlloc); | 74 | memmove(&ad[size], ad, iinfo->i_lenAlloc); |
74 | 75 | ||
75 | if (UDF_I(inode)->i_lenEAttr) { | 76 | if (iinfo->i_lenEAttr) { |
76 | /* check checksum/crc */ | 77 | /* check checksum/crc */ |
77 | if (eahd->descTag.tagIdent != | 78 | if (eahd->descTag.tagIdent != |
78 | cpu_to_le16(TAG_IDENT_EAHD) || | 79 | cpu_to_le16(TAG_IDENT_EAHD) || |
79 | le32_to_cpu(eahd->descTag.tagLocation) != | 80 | le32_to_cpu(eahd->descTag.tagLocation) != |
80 | UDF_I(inode)->i_location.logicalBlockNum) | 81 | iinfo->i_location.logicalBlockNum) |
81 | return NULL; | 82 | return NULL; |
82 | } else { | 83 | } else { |
83 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); | 84 | struct udf_sb_info *sbi = UDF_SB(inode->i_sb); |
84 | 85 | ||
85 | size -= sizeof(struct extendedAttrHeaderDesc); | 86 | size -= sizeof(struct extendedAttrHeaderDesc); |
86 | UDF_I(inode)->i_lenEAttr += | 87 | iinfo->i_lenEAttr += |
87 | sizeof(struct extendedAttrHeaderDesc); | 88 | sizeof(struct extendedAttrHeaderDesc); |
88 | eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); | 89 | eahd->descTag.tagIdent = cpu_to_le16(TAG_IDENT_EAHD); |
89 | if (sbi->s_udfrev >= 0x0200) | 90 | if (sbi->s_udfrev >= 0x0200) |
@@ -93,15 +94,15 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
93 | eahd->descTag.tagSerialNum = | 94 | eahd->descTag.tagSerialNum = |
94 | cpu_to_le16(sbi->s_serial_number); | 95 | cpu_to_le16(sbi->s_serial_number); |
95 | eahd->descTag.tagLocation = cpu_to_le32( | 96 | eahd->descTag.tagLocation = cpu_to_le32( |
96 | UDF_I(inode)->i_location.logicalBlockNum); | 97 | iinfo->i_location.logicalBlockNum); |
97 | eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); | 98 | eahd->impAttrLocation = cpu_to_le32(0xFFFFFFFF); |
98 | eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); | 99 | eahd->appAttrLocation = cpu_to_le32(0xFFFFFFFF); |
99 | } | 100 | } |
100 | 101 | ||
101 | offset = UDF_I(inode)->i_lenEAttr; | 102 | offset = iinfo->i_lenEAttr; |
102 | if (type < 2048) { | 103 | if (type < 2048) { |
103 | if (le32_to_cpu(eahd->appAttrLocation) < | 104 | if (le32_to_cpu(eahd->appAttrLocation) < |
104 | UDF_I(inode)->i_lenEAttr) { | 105 | iinfo->i_lenEAttr) { |
105 | uint32_t aal = | 106 | uint32_t aal = |
106 | le32_to_cpu(eahd->appAttrLocation); | 107 | le32_to_cpu(eahd->appAttrLocation); |
107 | memmove(&ea[offset - aal + size], | 108 | memmove(&ea[offset - aal + size], |
@@ -111,7 +112,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
111 | cpu_to_le32(aal + size); | 112 | cpu_to_le32(aal + size); |
112 | } | 113 | } |
113 | if (le32_to_cpu(eahd->impAttrLocation) < | 114 | if (le32_to_cpu(eahd->impAttrLocation) < |
114 | UDF_I(inode)->i_lenEAttr) { | 115 | iinfo->i_lenEAttr) { |
115 | uint32_t ial = | 116 | uint32_t ial = |
116 | le32_to_cpu(eahd->impAttrLocation); | 117 | le32_to_cpu(eahd->impAttrLocation); |
117 | memmove(&ea[offset - ial + size], | 118 | memmove(&ea[offset - ial + size], |
@@ -122,7 +123,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
122 | } | 123 | } |
123 | } else if (type < 65536) { | 124 | } else if (type < 65536) { |
124 | if (le32_to_cpu(eahd->appAttrLocation) < | 125 | if (le32_to_cpu(eahd->appAttrLocation) < |
125 | UDF_I(inode)->i_lenEAttr) { | 126 | iinfo->i_lenEAttr) { |
126 | uint32_t aal = | 127 | uint32_t aal = |
127 | le32_to_cpu(eahd->appAttrLocation); | 128 | le32_to_cpu(eahd->appAttrLocation); |
128 | memmove(&ea[offset - aal + size], | 129 | memmove(&ea[offset - aal + size], |
@@ -138,7 +139,7 @@ struct genericFormat *udf_add_extendedattr(struct inode *inode, uint32_t size, | |||
138 | eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd + | 139 | eahd->descTag.descCRC = cpu_to_le16(udf_crc((char *)eahd + |
139 | sizeof(tag), crclen, 0)); | 140 | sizeof(tag), crclen, 0)); |
140 | eahd->descTag.tagChecksum = udf_tag_checksum(&eahd->descTag); | 141 | eahd->descTag.tagChecksum = udf_tag_checksum(&eahd->descTag); |
141 | UDF_I(inode)->i_lenEAttr += size; | 142 | iinfo->i_lenEAttr += size; |
142 | return (struct genericFormat *)&ea[offset]; | 143 | return (struct genericFormat *)&ea[offset]; |
143 | } | 144 | } |
144 | if (loc & 0x02) | 145 | if (loc & 0x02) |
@@ -153,10 +154,11 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, | |||
153 | struct genericFormat *gaf; | 154 | struct genericFormat *gaf; |
154 | uint8_t *ea = NULL; | 155 | uint8_t *ea = NULL; |
155 | uint32_t offset; | 156 | uint32_t offset; |
157 | struct udf_inode_info *iinfo = UDF_I(inode); | ||
156 | 158 | ||
157 | ea = UDF_I(inode)->i_ext.i_data; | 159 | ea = iinfo->i_ext.i_data; |
158 | 160 | ||
159 | if (UDF_I(inode)->i_lenEAttr) { | 161 | if (iinfo->i_lenEAttr) { |
160 | struct extendedAttrHeaderDesc *eahd; | 162 | struct extendedAttrHeaderDesc *eahd; |
161 | eahd = (struct extendedAttrHeaderDesc *)ea; | 163 | eahd = (struct extendedAttrHeaderDesc *)ea; |
162 | 164 | ||
@@ -164,7 +166,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, | |||
164 | if (eahd->descTag.tagIdent != | 166 | if (eahd->descTag.tagIdent != |
165 | cpu_to_le16(TAG_IDENT_EAHD) || | 167 | cpu_to_le16(TAG_IDENT_EAHD) || |
166 | le32_to_cpu(eahd->descTag.tagLocation) != | 168 | le32_to_cpu(eahd->descTag.tagLocation) != |
167 | UDF_I(inode)->i_location.logicalBlockNum) | 169 | iinfo->i_location.logicalBlockNum) |
168 | return NULL; | 170 | return NULL; |
169 | 171 | ||
170 | if (type < 2048) | 172 | if (type < 2048) |
@@ -174,7 +176,7 @@ struct genericFormat *udf_get_extendedattr(struct inode *inode, uint32_t type, | |||
174 | else | 176 | else |
175 | offset = le32_to_cpu(eahd->appAttrLocation); | 177 | offset = le32_to_cpu(eahd->appAttrLocation); |
176 | 178 | ||
177 | while (offset < UDF_I(inode)->i_lenEAttr) { | 179 | while (offset < iinfo->i_lenEAttr) { |
178 | gaf = (struct genericFormat *)&ea[offset]; | 180 | gaf = (struct genericFormat *)&ea[offset]; |
179 | if (le32_to_cpu(gaf->attrType) == type && | 181 | if (le32_to_cpu(gaf->attrType) == type && |
180 | gaf->attrSubtype == subtype) | 182 | gaf->attrSubtype == subtype) |