2121 _cryptsetupOpen = cryptsetupOpen
2222 _generateKeyFile = generateKeyFile
2323 _osMkdirTemp = os .MkdirTemp
24- _mkfsXfs = mkfsXfs
2524 _osRemoveAll = os .RemoveAll
2625 _zeroFirstBlock = zeroFirstBlock
2726)
@@ -88,17 +87,6 @@ func cryptsetupClose(deviceName string) error {
8887 return cryptsetupCommand (closeArgs )
8988}
9089
91- // invoke mkfs.xfs for the given device.
92- func mkfsXfs (devicePath string ) error {
93- args := []string {"-f" , devicePath }
94- cmd := exec .Command ("mkfs.xfs" , args ... )
95- output , err := cmd .CombinedOutput ()
96- if err != nil {
97- return errors .Wrapf (err , "failed to execute mkfs.ext4: %s" , string (output ))
98- }
99- return nil
100- }
101-
10290// EncryptDevice creates a dm-crypt target for a container scratch vhd.
10391//
10492// In order to mount a block device as an encrypted device:
@@ -121,12 +109,11 @@ func mkfsXfs(devicePath string) error {
121109// /dev/mapper/`cryptDeviceTemplate`. This can be mounted directly, but it
122110// doesn't have any format yet.
123111//
124- // 4. Format the unencrypted block device as xfs.
112+ // 4. Prepare the unecrypted block device to be later formatted as xfs
125113// 4.1. Zero the first block. It appears that mkfs.xfs reads this before formatting.
126- // 4.2. Format the device as xfs.
127114
128115func EncryptDevice (ctx context.Context , source string , dmCryptName string ) (path string , err error ) {
129- // Create temporary directory to store the keyfile and EXT4 image
116+ // Create temporary directory to store the keyfile and xfs image
130117 tempDir , err := _osMkdirTemp ("" , "dm-crypt" )
131118 if err != nil {
132119 return "" , errors .Wrapf (err , "failed to create temporary folder: %s" , source )
@@ -172,11 +159,6 @@ func EncryptDevice(ctx context.Context, source string, dmCryptName string) (path
172159 return "" , fmt .Errorf ("failed to zero first block: %w" , err )
173160 }
174161
175- // 4.2. Format it as xfs
176- if err = _mkfsXfs (deviceNamePath ); err != nil {
177- return "" , fmt .Errorf ("mkfs.xfs failed to format %s: %w" , deviceNamePath , err )
178- }
179-
180162 return deviceNamePath , nil
181163}
182164
0 commit comments