Lines Matching refs:dst
34 static inline void ntfs_rl_mm(runlist_element *base, int dst, int src, in ntfs_rl_mm() argument
37 if (likely((dst != src) && (size > 0))) in ntfs_rl_mm()
38 memmove(base + dst, base + src, size * sizeof(*base)); in ntfs_rl_mm()
47 static inline void ntfs_rl_mc(runlist_element *dstbase, int dst, in ntfs_rl_mc() argument
51 memcpy(dstbase + dst, srcbase + src, size * sizeof(*dstbase)); in ntfs_rl_mc()
155 static inline bool ntfs_are_rl_mergeable(runlist_element *dst, in ntfs_are_rl_mergeable() argument
158 BUG_ON(!dst); in ntfs_are_rl_mergeable()
162 if ((dst->lcn == LCN_RL_NOT_MAPPED) && (src->lcn == LCN_RL_NOT_MAPPED)) in ntfs_are_rl_mergeable()
165 if ((dst->vcn + dst->length) != src->vcn) in ntfs_are_rl_mergeable()
168 if ((dst->lcn >= 0) && (src->lcn >= 0) && in ntfs_are_rl_mergeable()
169 ((dst->lcn + dst->length) == src->lcn)) in ntfs_are_rl_mergeable()
172 if ((dst->lcn == LCN_HOLE) && (src->lcn == LCN_HOLE)) in ntfs_are_rl_mergeable()
189 static inline void __ntfs_rl_merge(runlist_element *dst, runlist_element *src) in __ntfs_rl_merge() argument
191 dst->length += src->length; in __ntfs_rl_merge()
218 static inline runlist_element *ntfs_rl_append(runlist_element *dst, in ntfs_rl_append() argument
224 BUG_ON(!dst); in ntfs_rl_append()
229 right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1); in ntfs_rl_append()
232 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - right); in ntfs_rl_append()
233 if (IS_ERR(dst)) in ntfs_rl_append()
234 return dst; in ntfs_rl_append()
242 __ntfs_rl_merge(src + ssize - 1, dst + loc + 1); in ntfs_rl_append()
248 ntfs_rl_mm(dst, marker, loc + 1 + right, dsize - (loc + 1 + right)); in ntfs_rl_append()
249 ntfs_rl_mc(dst, loc + 1, src, 0, ssize); in ntfs_rl_append()
252 dst[loc].length = dst[loc + 1].vcn - dst[loc].vcn; in ntfs_rl_append()
255 if (dst[marker].lcn == LCN_ENOENT) in ntfs_rl_append()
256 dst[marker].vcn = dst[marker - 1].vcn + dst[marker - 1].length; in ntfs_rl_append()
258 return dst; in ntfs_rl_append()
285 static inline runlist_element *ntfs_rl_insert(runlist_element *dst, in ntfs_rl_insert() argument
292 BUG_ON(!dst); in ntfs_rl_insert()
304 left = ntfs_are_rl_mergeable(dst + loc - 1, src); in ntfs_rl_insert()
306 merged_length = dst[loc - 1].length; in ntfs_rl_insert()
310 disc = (src[0].vcn > dst[loc - 1].vcn + merged_length); in ntfs_rl_insert()
316 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize - left + disc); in ntfs_rl_insert()
317 if (IS_ERR(dst)) in ntfs_rl_insert()
318 return dst; in ntfs_rl_insert()
324 __ntfs_rl_merge(dst + loc - 1, src); in ntfs_rl_insert()
335 ntfs_rl_mm(dst, marker, loc, dsize - loc); in ntfs_rl_insert()
336 ntfs_rl_mc(dst, loc + disc, src, left, ssize - left); in ntfs_rl_insert()
339 dst[marker].vcn = dst[marker - 1].vcn + dst[marker - 1].length; in ntfs_rl_insert()
341 if (dst[marker].lcn == LCN_HOLE || dst[marker].lcn == LCN_RL_NOT_MAPPED) in ntfs_rl_insert()
342 dst[marker].length = dst[marker + 1].vcn - dst[marker].vcn; in ntfs_rl_insert()
347 dst[loc].vcn = dst[loc - 1].vcn + dst[loc - 1].length; in ntfs_rl_insert()
348 dst[loc].length = dst[loc + 1].vcn - dst[loc].vcn; in ntfs_rl_insert()
350 dst[loc].vcn = 0; in ntfs_rl_insert()
351 dst[loc].length = dst[loc + 1].vcn; in ntfs_rl_insert()
353 dst[loc].lcn = LCN_RL_NOT_MAPPED; in ntfs_rl_insert()
355 return dst; in ntfs_rl_insert()
381 static inline runlist_element *ntfs_rl_replace(runlist_element *dst, in ntfs_rl_replace() argument
390 BUG_ON(!dst); in ntfs_rl_replace()
395 right = ntfs_are_rl_mergeable(src + ssize - 1, dst + loc + 1); in ntfs_rl_replace()
397 left = ntfs_are_rl_mergeable(dst + loc - 1, src); in ntfs_rl_replace()
404 dst = ntfs_rl_realloc(dst, dsize, dsize + delta); in ntfs_rl_replace()
405 if (IS_ERR(dst)) in ntfs_rl_replace()
406 return dst; in ntfs_rl_replace()
415 __ntfs_rl_merge(src + ssize - 1, dst + loc + 1); in ntfs_rl_replace()
417 __ntfs_rl_merge(dst + loc - 1, src); in ntfs_rl_replace()
437 ntfs_rl_mm(dst, marker, tail, dsize - tail); in ntfs_rl_replace()
438 ntfs_rl_mc(dst, loc, src, left, ssize - left); in ntfs_rl_replace()
441 if (dsize - tail > 0 && dst[marker].lcn == LCN_ENOENT) in ntfs_rl_replace()
442 dst[marker].vcn = dst[marker - 1].vcn + dst[marker - 1].length; in ntfs_rl_replace()
443 return dst; in ntfs_rl_replace()
470 static inline runlist_element *ntfs_rl_split(runlist_element *dst, int dsize, in ntfs_rl_split() argument
473 BUG_ON(!dst); in ntfs_rl_split()
477 dst = ntfs_rl_realloc(dst, dsize, dsize + ssize + 1); in ntfs_rl_split()
478 if (IS_ERR(dst)) in ntfs_rl_split()
479 return dst; in ntfs_rl_split()
486 ntfs_rl_mm(dst, loc + 1 + ssize, loc, dsize - loc); in ntfs_rl_split()
487 ntfs_rl_mc(dst, loc + 1, src, 0, ssize); in ntfs_rl_split()
490 dst[loc].length = dst[loc+1].vcn - dst[loc].vcn; in ntfs_rl_split()
491 dst[loc+ssize+1].vcn = dst[loc+ssize].vcn + dst[loc+ssize].length; in ntfs_rl_split()
492 dst[loc+ssize+1].length = dst[loc+ssize+2].vcn - dst[loc+ssize+1].vcn; in ntfs_rl_split()
494 return dst; in ntfs_rl_split()
1252 static inline int ntfs_write_significant_bytes(s8 *dst, const s8 *dst_max, in ntfs_write_significant_bytes() argument
1261 if (unlikely(dst > dst_max)) in ntfs_write_significant_bytes()
1263 *dst++ = l & 0xffll; in ntfs_write_significant_bytes()
1270 if (unlikely(dst > dst_max)) in ntfs_write_significant_bytes()
1273 *dst = (s8)-1; in ntfs_write_significant_bytes()
1275 if (unlikely(dst > dst_max)) in ntfs_write_significant_bytes()
1278 *dst = (s8)0; in ntfs_write_significant_bytes()
1323 int ntfs_mapping_pairs_build(const ntfs_volume *vol, s8 *dst, in ntfs_mapping_pairs_build() argument
1343 *dst = 0; in ntfs_mapping_pairs_build()
1356 dst_max = dst + dst_len - 1; in ntfs_mapping_pairs_build()
1377 len_len = ntfs_write_significant_bytes(dst + 1, dst_max, in ntfs_mapping_pairs_build()
1395 lcn_len = ntfs_write_significant_bytes(dst + 1 + in ntfs_mapping_pairs_build()
1401 dst_next = dst + len_len + lcn_len + 1; in ntfs_mapping_pairs_build()
1405 *dst = lcn_len << 4 | len_len; in ntfs_mapping_pairs_build()
1407 dst = dst_next; in ntfs_mapping_pairs_build()
1428 len_len = ntfs_write_significant_bytes(dst + 1, dst_max, in ntfs_mapping_pairs_build()
1443 lcn_len = ntfs_write_significant_bytes(dst + 1 + in ntfs_mapping_pairs_build()
1450 dst_next = dst + len_len + lcn_len + 1; in ntfs_mapping_pairs_build()
1454 *dst = lcn_len << 4 | len_len; in ntfs_mapping_pairs_build()
1456 dst = dst_next; in ntfs_mapping_pairs_build()
1465 *dst = 0; in ntfs_mapping_pairs_build()