@@ -11,15 +11,28 @@ use std::num::NonZeroU64;
1111/// If you need to clone an entire file, consider using the [`reflink`] or [`reflink_or_copy`]
1212/// functions instead.
1313///
14- /// > Note: Currently the function works only for windows. It returns `Err` for any other platform.
14+ /// > Note: Currently the function works only for windows and linux platforms. It returns `Err` for
15+ /// any other platform.
1516///
1617/// # General restrictions
18+ ///
1719/// - The source and destination regions must begin and end at a cluster boundary.
1820/// - If the source and destination regions are in the same file, they must not overlap. (The
1921/// application may able to proceed by splitting up the block clone operation into multiple block
2022/// clones that no longer overlap.)
23+ /// - `src_length` equal to 0 is not supported.
24+ ///
25+ /// # Linux specific restrictions and remarks
26+ ///
27+ /// - If the file size is not aligned to the cluster size, the reflink operation must not exceed
28+ /// the file length. For example, to reflink the whole file with size of 7000 bytes, `src_length`
29+ /// should be 7000 bytes.
30+ ///
31+ /// More information about block cloning on Linux can be found by the
32+ /// [link](https://www.man7.org/linux/man-pages/man2/ioctl_ficlonerange.2.html).
2133///
2234/// # Windows specific restrictions and remarks
35+ ///
2336/// - The destination region must not extend past the end of file. If the application wishes to
2437/// extend the destination with cloned data, it must first call
2538/// [`File::set_len`](fn@std::fs::File::set_len).
@@ -32,6 +45,9 @@ use std::num::NonZeroU64;
3245/// - The ReFS volume must have been formatted with Windows Server 2016, and if Windows Failover
3346/// Clustering is in use, the Clustering Functional Level must have been Windows Server 2016 or
3447/// later at format time.
48+ /// - If the file size is not aligned to the cluster size, the reflink operation should still
49+ /// be aligned by the cluster size. For example, to reflink the whole file with size of 7000 bytes
50+ /// and a cluster size of 4096 bytes, `src_length` should be 8192 bytes.
3551///
3652/// > Note: In order to handle blocks larger than 4GB,
3753/// [`ReflinkBlockBuilder::reflink_block`] splits these big blocks into smaller ones.
@@ -117,18 +133,14 @@ impl<'from, 'to> ReflinkBlockBuilder<'from, 'to> {
117133 }
118134
119135 /// Performs reflink operation for the specified block of data.
120- #[ cfg_attr( not( windows) , allow( unused_variables) ) ]
121136 pub fn reflink_block ( self ) -> io:: Result < ( ) > {
122- #[ cfg( windows) ]
123- return sys:: reflink_block (
137+ sys:: reflink_block (
124138 self . from ,
125139 self . from_offset ,
126140 self . to ,
127141 self . to_offset ,
128142 self . src_length ,
129143 self . cluster_size ,
130- ) ;
131- #[ cfg( not( windows) ) ]
132- Err ( io:: Error :: other ( "Not implemented" ) )
144+ )
133145 }
134146}
0 commit comments