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

TOMOYO Linux Cross Reference
Linux/fs/ntfs3/bitfunc.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /fs/ntfs3/bitfunc.c (Version linux-6.11.5) and /fs/ntfs3/bitfunc.c (Version linux-5.5.19)


  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*                                                
  3  *                                                
  4  * Copyright (C) 2019-2021 Paragon Software Gm    
  5  *                                                
  6  */                                               
  7                                                   
  8 #include <linux/types.h>                          
  9                                                   
 10 #include "ntfs_fs.h"                              
 11                                                   
 12 #define BITS_IN_SIZE_T (sizeof(size_t) * 8)       
 13                                                   
 14 /*                                                
 15  * fill_mask[i] - first i bits are '1' , i = 0    
 16  * fill_mask[i] = 0xFF >> (8-i)                   
 17  */                                               
 18 static const u8 fill_mask[] = { 0x00, 0x01, 0x    
 19                                 0x1F, 0x3F, 0x    
 20                                                   
 21 /*                                                
 22  * zero_mask[i] - first i bits are '' , i = 0,    
 23  * zero_mask[i] = 0xFF << i                       
 24  */                                               
 25 static const u8 zero_mask[] = { 0xFF, 0xFE, 0x    
 26                                 0xE0, 0xC0, 0x    
 27                                                   
 28 /*                                                
 29  * are_bits_clear                                 
 30  *                                                
 31  * Return: True if all bits [bit, bit+nbits) a    
 32  */                                               
 33 bool are_bits_clear(const void *lmap, size_t b    
 34 {                                                 
 35         size_t pos = bit & 7;                     
 36         const u8 *map = (u8 *)lmap + (bit >> 3    
 37                                                   
 38         if (pos) {                                
 39                 if (8 - pos >= nbits)             
 40                         return !nbits || !(*ma    
 41                                            zer    
 42                                                   
 43                 if (*map++ & zero_mask[pos])      
 44                         return false;             
 45                 nbits -= 8 - pos;                 
 46         }                                         
 47                                                   
 48         pos = ((size_t)map) & (sizeof(size_t)     
 49         if (pos) {                                
 50                 pos = sizeof(size_t) - pos;       
 51                 if (nbits >= pos * 8) {           
 52                         for (nbits -= pos * 8;    
 53                                 if (*map)         
 54                                         return    
 55                         }                         
 56                 }                                 
 57         }                                         
 58                                                   
 59         for (pos = nbits / BITS_IN_SIZE_T; pos    
 60                 if (*((size_t *)map))             
 61                         return false;             
 62         }                                         
 63                                                   
 64         for (pos = (nbits % BITS_IN_SIZE_T) >>    
 65                 if (*map)                         
 66                         return false;             
 67         }                                         
 68                                                   
 69         pos = nbits & 7;                          
 70         if (pos && (*map & fill_mask[pos]))       
 71                 return false;                     
 72                                                   
 73         return true;                              
 74 }                                                 
 75                                                   
 76 /*                                                
 77  * are_bits_set                                   
 78  *                                                
 79  * Return: True if all bits [bit, bit+nbits) a    
 80  */                                               
 81 bool are_bits_set(const void *lmap, size_t bit    
 82 {                                                 
 83         u8 mask;                                  
 84         size_t pos = bit & 7;                     
 85         const u8 *map = (u8 *)lmap + (bit >> 3    
 86                                                   
 87         if (pos) {                                
 88                 if (8 - pos >= nbits) {           
 89                         mask = fill_mask[pos +    
 90                         return !nbits || (*map    
 91                 }                                 
 92                                                   
 93                 mask = zero_mask[pos];            
 94                 if ((*map++ & mask) != mask)      
 95                         return false;             
 96                 nbits -= 8 - pos;                 
 97         }                                         
 98                                                   
 99         pos = ((size_t)map) & (sizeof(size_t)     
100         if (pos) {                                
101                 pos = sizeof(size_t) - pos;       
102                 if (nbits >= pos * 8) {           
103                         for (nbits -= pos * 8;    
104                                 if (*map != 0x    
105                                         return    
106                         }                         
107                 }                                 
108         }                                         
109                                                   
110         for (pos = nbits / BITS_IN_SIZE_T; pos    
111                 if (*((size_t *)map) != MINUS_    
112                         return false;             
113         }                                         
114                                                   
115         for (pos = (nbits % BITS_IN_SIZE_T) >>    
116                 if (*map != 0xFF)                 
117                         return false;             
118         }                                         
119                                                   
120         pos = nbits & 7;                          
121         if (pos) {                                
122                 mask = fill_mask[pos];            
123                 if ((*map & mask) != mask)        
124                         return false;             
125         }                                         
126                                                   
127         return true;                              
128 }                                                 
129                                                   

~ [ 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