bitmap.c (e5451c8f8330e03ad3cfa16048b4daf961af434f) | bitmap.c (09cbfeaf1a5a67bfb3201e0c83c810cecb2efa5a) |
---|---|
1/* 2 * bitmap.c - NTFS kernel bitmap handling. Part of the Linux-NTFS project. 3 * 4 * Copyright (c) 2004-2005 Anton Altaparmakov 5 * 6 * This program/include file is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as published 8 * by the Free Software Foundation; either version 2 of the License, or --- 53 unchanged lines hidden (view full) --- 62 is_rollback ? " (rollback)" : ""); 63 BUG_ON(start_bit < 0); 64 BUG_ON(cnt < 0); 65 BUG_ON(value > 1); 66 /* 67 * Calculate the indices for the pages containing the first and last 68 * bits, i.e. @start_bit and @start_bit + @cnt - 1, respectively. 69 */ | 1/* 2 * bitmap.c - NTFS kernel bitmap handling. Part of the Linux-NTFS project. 3 * 4 * Copyright (c) 2004-2005 Anton Altaparmakov 5 * 6 * This program/include file is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as published 8 * by the Free Software Foundation; either version 2 of the License, or --- 53 unchanged lines hidden (view full) --- 62 is_rollback ? " (rollback)" : ""); 63 BUG_ON(start_bit < 0); 64 BUG_ON(cnt < 0); 65 BUG_ON(value > 1); 66 /* 67 * Calculate the indices for the pages containing the first and last 68 * bits, i.e. @start_bit and @start_bit + @cnt - 1, respectively. 69 */ |
70 index = start_bit >> (3 + PAGE_CACHE_SHIFT); 71 end_index = (start_bit + cnt - 1) >> (3 + PAGE_CACHE_SHIFT); | 70 index = start_bit >> (3 + PAGE_SHIFT); 71 end_index = (start_bit + cnt - 1) >> (3 + PAGE_SHIFT); |
72 73 /* Get the page containing the first bit (@start_bit). */ 74 mapping = vi->i_mapping; 75 page = ntfs_map_page(mapping, index); 76 if (IS_ERR(page)) { 77 if (!is_rollback) 78 ntfs_error(vi->i_sb, "Failed to map first page (error " 79 "%li), aborting.", PTR_ERR(page)); 80 return PTR_ERR(page); 81 } 82 kaddr = page_address(page); 83 84 /* Set @pos to the position of the byte containing @start_bit. */ | 72 73 /* Get the page containing the first bit (@start_bit). */ 74 mapping = vi->i_mapping; 75 page = ntfs_map_page(mapping, index); 76 if (IS_ERR(page)) { 77 if (!is_rollback) 78 ntfs_error(vi->i_sb, "Failed to map first page (error " 79 "%li), aborting.", PTR_ERR(page)); 80 return PTR_ERR(page); 81 } 82 kaddr = page_address(page); 83 84 /* Set @pos to the position of the byte containing @start_bit. */ |
85 pos = (start_bit >> 3) & ~PAGE_CACHE_MASK; | 85 pos = (start_bit >> 3) & ~PAGE_MASK; |
86 87 /* Calculate the position of @start_bit in the first byte. */ 88 bit = start_bit & 7; 89 90 /* If the first byte is partial, modify the appropriate bits in it. */ 91 if (bit) { 92 u8 *byte = kaddr + pos; 93 while ((bit & 7) && cnt) { --- 9 unchanged lines hidden (view full) --- 103 104 /* Update @pos to the new position. */ 105 pos++; 106 } 107 /* 108 * Depending on @value, modify all remaining whole bytes in the page up 109 * to @cnt. 110 */ | 86 87 /* Calculate the position of @start_bit in the first byte. */ 88 bit = start_bit & 7; 89 90 /* If the first byte is partial, modify the appropriate bits in it. */ 91 if (bit) { 92 u8 *byte = kaddr + pos; 93 while ((bit & 7) && cnt) { --- 9 unchanged lines hidden (view full) --- 103 104 /* Update @pos to the new position. */ 105 pos++; 106 } 107 /* 108 * Depending on @value, modify all remaining whole bytes in the page up 109 * to @cnt. 110 */ |
111 len = min_t(s64, cnt >> 3, PAGE_CACHE_SIZE - pos); | 111 len = min_t(s64, cnt >> 3, PAGE_SIZE - pos); |
112 memset(kaddr + pos, value ? 0xff : 0, len); 113 cnt -= len << 3; 114 115 /* Update @len to point to the first not-done byte in the page. */ 116 if (cnt < 8) 117 len += pos; 118 119 /* If we are not in the last page, deal with all subsequent pages. */ --- 7 unchanged lines hidden (view full) --- 127 page = ntfs_map_page(mapping, ++index); 128 if (IS_ERR(page)) 129 goto rollback; 130 kaddr = page_address(page); 131 /* 132 * Depending on @value, modify all remaining whole bytes in the 133 * page up to @cnt. 134 */ | 112 memset(kaddr + pos, value ? 0xff : 0, len); 113 cnt -= len << 3; 114 115 /* Update @len to point to the first not-done byte in the page. */ 116 if (cnt < 8) 117 len += pos; 118 119 /* If we are not in the last page, deal with all subsequent pages. */ --- 7 unchanged lines hidden (view full) --- 127 page = ntfs_map_page(mapping, ++index); 128 if (IS_ERR(page)) 129 goto rollback; 130 kaddr = page_address(page); 131 /* 132 * Depending on @value, modify all remaining whole bytes in the 133 * page up to @cnt. 134 */ |
135 len = min_t(s64, cnt >> 3, PAGE_CACHE_SIZE); | 135 len = min_t(s64, cnt >> 3, PAGE_SIZE); |
136 memset(kaddr, value ? 0xff : 0, len); 137 cnt -= len << 3; 138 } 139 /* 140 * The currently mapped page is the last one. If the last byte is 141 * partial, modify the appropriate bits in it. Note, @len is the 142 * position of the last byte inside the page. 143 */ --- 50 unchanged lines hidden --- | 136 memset(kaddr, value ? 0xff : 0, len); 137 cnt -= len << 3; 138 } 139 /* 140 * The currently mapped page is the last one. If the last byte is 141 * partial, modify the appropriate bits in it. Note, @len is the 142 * position of the last byte inside the page. 143 */ --- 50 unchanged lines hidden --- |