~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/hpfs/map.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/hpfs/map.c (Version linux-6.12-rc7) and /fs/hpfs/map.c (Version unix-v6-master)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  *  linux/fs/hpfs/map.c                           
  4  *                                                
  5  *  Mikulas Patocka (mikulas@artax.karlin.mff.    
  6  *                                                
  7  *  mapping structures to memory with some min    
  8  */                                               
  9                                                   
 10 #include "hpfs_fn.h"                              
 11                                                   
 12 __le32 *hpfs_map_dnode_bitmap(struct super_blo    
 13 {                                                 
 14         return hpfs_map_4sectors(s, hpfs_sb(s)    
 15 }                                                 
 16                                                   
 17 __le32 *hpfs_map_bitmap(struct super_block *s,    
 18                          struct quad_buffer_he    
 19 {                                                 
 20         secno sec;                                
 21         __le32 *ret;                              
 22         unsigned n_bands = (hpfs_sb(s)->sb_fs_    
 23         if (hpfs_sb(s)->sb_chk) if (bmp_block     
 24                 hpfs_error(s, "hpfs_map_bitmap    
 25                 return NULL;                      
 26         }                                         
 27         sec = le32_to_cpu(hpfs_sb(s)->sb_bmp_d    
 28         if (!sec || sec > hpfs_sb(s)->sb_fs_si    
 29                 hpfs_error(s, "invalid bitmap     
 30                 return NULL;                      
 31         }                                         
 32         ret = hpfs_map_4sectors(s, sec, qbh, 4    
 33         if (ret) hpfs_prefetch_bitmap(s, bmp_b    
 34         return ret;                               
 35 }                                                 
 36                                                   
 37 void hpfs_prefetch_bitmap(struct super_block *    
 38 {                                                 
 39         unsigned to_prefetch, next_prefetch;      
 40         unsigned n_bands = (hpfs_sb(s)->sb_fs_    
 41         if (unlikely(bmp_block >= n_bands))       
 42                 return;                           
 43         to_prefetch = le32_to_cpu(hpfs_sb(s)->    
 44         if (unlikely(bmp_block + 1 >= n_bands)    
 45                 next_prefetch = 0;                
 46         else                                      
 47                 next_prefetch = le32_to_cpu(hp    
 48         hpfs_prefetch_sectors(s, to_prefetch,     
 49 }                                                 
 50                                                   
 51 /*                                                
 52  * Load first code page into kernel memory, re    
 53  * first 128 bytes are uppercasing table for c    
 54  * lowercasing table                              
 55  */                                               
 56                                                   
 57 unsigned char *hpfs_load_code_page(struct supe    
 58 {                                                 
 59         struct buffer_head *bh;                   
 60         secno cpds;                               
 61         unsigned cpi;                             
 62         unsigned char *ptr;                       
 63         unsigned char *cp_table;                  
 64         int i;                                    
 65         struct code_page_data *cpd;               
 66         struct code_page_directory *cp = hpfs_    
 67         if (!cp) return NULL;                     
 68         if (le32_to_cpu(cp->magic) != CP_DIR_M    
 69                 pr_err("Code page directory ma    
 70                         le32_to_cpu(cp->magic)    
 71                 brelse(bh);                       
 72                 return NULL;                      
 73         }                                         
 74         if (!le32_to_cpu(cp->n_code_pages)) {     
 75                 pr_err("n_code_pages == 0\n");    
 76                 brelse(bh);                       
 77                 return NULL;                      
 78         }                                         
 79         cpds = le32_to_cpu(cp->array[0].code_p    
 80         cpi = le16_to_cpu(cp->array[0].index);    
 81         brelse(bh);                               
 82                                                   
 83         if (cpi >= 3) {                           
 84                 pr_err("Code page index out of    
 85                 return NULL;                      
 86         }                                         
 87                                                   
 88         if (!(cpd = hpfs_map_sector(s, cpds, &    
 89         if (le16_to_cpu(cpd->offs[cpi]) > 0x17    
 90                 pr_err("Code page index out of    
 91                 brelse(bh);                       
 92                 return NULL;                      
 93         }                                         
 94         ptr = (unsigned char *)cpd + le16_to_c    
 95         if (!(cp_table = kmalloc(256, GFP_KERN    
 96                 pr_err("out of memory for code    
 97                 brelse(bh);                       
 98                 return NULL;                      
 99         }                                         
100         memcpy(cp_table, ptr, 128);               
101         brelse(bh);                               
102                                                   
103         /* Try to build lowercasing table from    
104                                                   
105         for (i=128; i<256; i++) cp_table[i]=i;    
106         for (i=128; i<256; i++) if (cp_table[i    
107                 cp_table[cp_table[i-128]] = i;    
108                                                   
109         return cp_table;                          
110 }                                                 
111                                                   
112 __le32 *hpfs_load_bitmap_directory(struct supe    
113 {                                                 
114         struct buffer_head *bh;                   
115         int n = (hpfs_sb(s)->sb_fs_size + 0x20    
116         int i;                                    
117         __le32 *b;                                
118         if (!(b = kmalloc_array(n, 512, GFP_KE    
119                 pr_err("can't allocate memory     
120                 return NULL;                      
121         }                                         
122         for (i=0;i<n;i++) {                       
123                 __le32 *d = hpfs_map_sector(s,    
124                 if (!d) {                         
125                         kfree(b);                 
126                         return NULL;              
127                 }                                 
128                 memcpy((char *)b + 512 * i, d,    
129                 brelse(bh);                       
130         }                                         
131         return b;                                 
132 }                                                 
133                                                   
134 void hpfs_load_hotfix_map(struct super_block *    
135 {                                                 
136         struct quad_buffer_head qbh;              
137         __le32 *directory;                        
138         u32 n_hotfixes, n_used_hotfixes;          
139         unsigned i;                               
140                                                   
141         n_hotfixes = le32_to_cpu(spareblock->n    
142         n_used_hotfixes = le32_to_cpu(spareblo    
143                                                   
144         if (n_hotfixes > 256 || n_used_hotfixe    
145                 hpfs_error(s, "invalid number     
146                 return;                           
147         }                                         
148         if (!(directory = hpfs_map_4sectors(s,    
149                 hpfs_error(s, "can't load hotf    
150                 return;                           
151         }                                         
152         for (i = 0; i < n_used_hotfixes; i++)     
153                 hpfs_sb(s)->hotfix_from[i] = l    
154                 hpfs_sb(s)->hotfix_to[i] = le3    
155         }                                         
156         hpfs_sb(s)->n_hotfixes = n_used_hotfix    
157         hpfs_brelse4(&qbh);                       
158 }                                                 
159                                                   
160 /*                                                
161  * Load fnode to memory                           
162  */                                               
163                                                   
164 struct fnode *hpfs_map_fnode(struct super_bloc    
165 {                                                 
166         struct fnode *fnode;                      
167         if (hpfs_sb(s)->sb_chk) if (hpfs_chk_s    
168                 return NULL;                      
169         }                                         
170         if ((fnode = hpfs_map_sector(s, ino, b    
171                 if (hpfs_sb(s)->sb_chk) {         
172                         struct extended_attrib    
173                         struct extended_attrib    
174                         if (le32_to_cpu(fnode-    
175                                 hpfs_error(s,     
176                                         (unsig    
177                                 goto bail;        
178                         }                         
179                         if (!fnode_is_dir(fnod    
180                                 if ((unsigned)    
181                                     (bp_intern    
182                                         hpfs_e    
183                                            "ba    
184                                             (u    
185                                         goto b    
186                                 }                 
187                                 if (le16_to_cp    
188                                     8 + fnode-    
189                                         hpfs_e    
190                                             "b    
191                                             (u    
192                                         goto b    
193                                 }                 
194                         }                         
195                         if (le16_to_cpu(fnode-    
196                            le16_to_cpu(fnode->    
197                                 hpfs_error(s,     
198                                         "bad E    
199                                         (unsig    
200                                         le16_t    
201                                 goto bail;        
202                         }                         
203                         ea = fnode_ea(fnode);     
204                         ea_end = fnode_end_ea(    
205                         while (ea != ea_end) {    
206                                 if (ea > ea_en    
207                                         hpfs_e    
208                                                   
209                                         goto b    
210                                 }                 
211                                 ea = next_ea(e    
212                         }                         
213                 }                                 
214         }                                         
215         return fnode;                             
216         bail:                                     
217         brelse(*bhp);                             
218         return NULL;                              
219 }                                                 
220                                                   
221 struct anode *hpfs_map_anode(struct super_bloc    
222 {                                                 
223         struct anode *anode;                      
224         if (hpfs_sb(s)->sb_chk) if (hpfs_chk_s    
225         if ((anode = hpfs_map_sector(s, ano, b    
226                 if (hpfs_sb(s)->sb_chk) {         
227                         if (le32_to_cpu(anode-    
228                                 hpfs_error(s,     
229                                 goto bail;        
230                         }                         
231                         if (le32_to_cpu(anode-    
232                                 hpfs_error(s,     
233                                 goto bail;        
234                         }                         
235                         if ((unsigned)anode->b    
236                             (bp_internal(&anod    
237                                 hpfs_error(s,     
238                                 goto bail;        
239                         }                         
240                         if (le16_to_cpu(anode-    
241                             8 + anode->btree.n    
242                                 hpfs_error(s,     
243                                 goto bail;        
244                         }                         
245                 }                                 
246         return anode;                             
247         bail:                                     
248         brelse(*bhp);                             
249         return NULL;                              
250 }                                                 
251                                                   
252 /*                                                
253  * Load dnode to memory and do some checks        
254  */                                               
255                                                   
256 struct dnode *hpfs_map_dnode(struct super_bloc    
257                              struct quad_buffe    
258 {                                                 
259         struct dnode *dnode;                      
260         if (hpfs_sb(s)->sb_chk) {                 
261                 if (hpfs_chk_sectors(s, secno,    
262                 if (secno & 3) {                  
263                         hpfs_error(s, "dnode %    
264                         return NULL;              
265                 }                                 
266         }                                         
267         if ((dnode = hpfs_map_4sectors(s, secn    
268                 if (hpfs_sb(s)->sb_chk) {         
269                         unsigned p, pp = 0;       
270                         unsigned char *d = (un    
271                         int b = 0;                
272                         if (le32_to_cpu(dnode-    
273                                 hpfs_error(s,     
274                                 goto bail;        
275                         }                         
276                         if (le32_to_cpu(dnode-    
277                                 hpfs_error(s,     
278                         /* Check dirents - bad    
279                            loops or shooting t    
280                         if (le32_to_cpu(dnode-    
281                                 hpfs_error(s,     
282                                 goto bail;        
283                         }                         
284                         for (p = 20; p < le32_    
285                                 struct hpfs_di    
286                                 if (le16_to_cp    
287                                         hpfs_e    
288                                         goto b    
289                                 }                 
290                                 if (((31 + de-    
291                                         if (((    
292                                         hpfs_e    
293                                         goto b    
294                                 }                 
295                                 ok:               
296                                 if (hpfs_sb(s)    
297                                 if (de->down)     
298                                         hpfs_e    
299                                         goto b    
300                                 }                 
301                                 pp = p;           
302                                                   
303                         }                         
304                         if (p != le32_to_cpu(d    
305                                 hpfs_error(s,     
306                                 goto bail;        
307                         }                         
308                         if (d[pp + 30] != 1 ||    
309                                 hpfs_error(s,     
310                                 goto bail;        
311                         }                         
312                         if (b == 3)               
313                                 pr_err("unbala    
314                                         secno)    
315                 }                                 
316         return dnode;                             
317         bail:                                     
318         hpfs_brelse4(qbh);                        
319         return NULL;                              
320 }                                                 
321                                                   
322 dnode_secno hpfs_fnode_dno(struct super_block     
323 {                                                 
324         struct buffer_head *bh;                   
325         struct fnode *fnode;                      
326         dnode_secno dno;                          
327                                                   
328         fnode = hpfs_map_fnode(s, ino, &bh);      
329         if (!fnode)                               
330                 return 0;                         
331                                                   
332         dno = le32_to_cpu(fnode->u.external[0]    
333         brelse(bh);                               
334         return dno;                               
335 }                                                 
336                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php