• Home
  • Raw
  • Download

Lines Matching +full:data +full:- +full:transfer

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * mst.c - NTFS multi sector transfer protection handling code. Part of the
4 * Linux-NTFS project.
6 * Copyright (c) 2001-2004 Anton Altaparmakov
12 * post_read_mst_fixup - deprotect multi sector transfer protected data
13 * @b: pointer to the data to deprotect
16 * Perform the necessary post read multi sector transfer fixup and detect the
17 * presence of incomplete multi sector transfers. - In that case, overwrite the
21 * Return 0 on success and -EINVAL on error ("BAAD" magic will be present).
34 usa_ofs = le16_to_cpu(b->usa_ofs); in post_read_mst_fixup()
36 usa_count = le16_to_cpu(b->usa_count) - 1; in post_read_mst_fixup()
38 if ( size & (NTFS_BLOCK_SIZE - 1) || in post_read_mst_fixup()
48 * endianness since we are comparing and moving data for on disk in post_read_mst_fixup()
49 * structures which means the data is consistent. - If it is in post_read_mst_fixup()
54 * Position in protected data of first u16 that needs fixing up. in post_read_mst_fixup()
56 data_pos = (u16*)b + NTFS_BLOCK_SIZE/sizeof(u16) - 1; in post_read_mst_fixup()
58 * Check for incomplete multi sector transfer(s). in post_read_mst_fixup()
60 while (usa_count--) { in post_read_mst_fixup()
63 * Incomplete multi sector transfer detected! )-: in post_read_mst_fixup()
67 b->magic = magic_BAAD; in post_read_mst_fixup()
68 return -EINVAL; in post_read_mst_fixup()
72 /* Re-setup the variables. */ in post_read_mst_fixup()
73 usa_count = le16_to_cpu(b->usa_count) - 1; in post_read_mst_fixup()
74 data_pos = (u16*)b + NTFS_BLOCK_SIZE/sizeof(u16) - 1; in post_read_mst_fixup()
76 while (usa_count--) { in post_read_mst_fixup()
78 * Increment position in usa and restore original data from in post_read_mst_fixup()
79 * the usa into the data buffer. in post_read_mst_fixup()
82 /* Increment position in data as well. */ in post_read_mst_fixup()
89 * pre_write_mst_fixup - apply multi sector transfer protection
90 * @b: pointer to the data to protect
93 * Perform the necessary pre write multi sector transfer fixup on the data
96 * Return 0 if fixup applied (success) or -EINVAL if no fixup was performed
116 if (!b || ntfs_is_baad_record(b->magic) || in pre_write_mst_fixup()
117 ntfs_is_hole_record(b->magic)) in pre_write_mst_fixup()
118 return -EINVAL; in pre_write_mst_fixup()
120 usa_ofs = le16_to_cpu(b->usa_ofs); in pre_write_mst_fixup()
122 usa_count = le16_to_cpu(b->usa_count) - 1; in pre_write_mst_fixup()
124 if ( size & (NTFS_BLOCK_SIZE - 1) || in pre_write_mst_fixup()
128 return -EINVAL; in pre_write_mst_fixup()
133 * (skipping 0 and -1, i.e. 0xffff). in pre_write_mst_fixup()
140 /* Position in data of first u16 that needs fixing up. */ in pre_write_mst_fixup()
141 data_pos = (le16*)b + NTFS_BLOCK_SIZE/sizeof(le16) - 1; in pre_write_mst_fixup()
143 while (usa_count--) { in pre_write_mst_fixup()
146 * original data from the data buffer into the usa. in pre_write_mst_fixup()
149 /* Apply fixup to data. */ in pre_write_mst_fixup()
151 /* Increment position in data as well. */ in pre_write_mst_fixup()
158 * post_write_mst_fixup - fast deprotect multi sector transfer protected data
159 * @b: pointer to the data to deprotect
161 * Perform the necessary post write multi sector transfer fixup, not checking
163 * thus the data will be fine or we would never have gotten here.
169 u16 usa_ofs = le16_to_cpu(b->usa_ofs); in post_write_mst_fixup()
170 u16 usa_count = le16_to_cpu(b->usa_count) - 1; in post_write_mst_fixup()
175 /* Position in protected data of first u16 that needs fixing up. */ in post_write_mst_fixup()
176 data_pos = (le16*)b + NTFS_BLOCK_SIZE/sizeof(le16) - 1; in post_write_mst_fixup()
179 while (usa_count--) { in post_write_mst_fixup()
181 * Increment position in usa and restore original data from in post_write_mst_fixup()
182 * the usa into the data buffer. in post_write_mst_fixup()
186 /* Increment position in data as well. */ in post_write_mst_fixup()