1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

filesize: fix alpine linux sparse file (#4288)

* fix sparse file creation on Alpine linux

* re-enable tests for Alpine
* remove `conv=sparse` flag (rely only on `seek=fullsize` & `count=0`)
* doc: add a reference to busybox's dd
* doc: remove restrictions for OpenBSD, Solaris & AIX (should work as
  for Alpine linux now)
* add a changelog fragment

* fix typo

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
quidame 2022-02-27 13:45:41 +01:00 committed by GitHub
parent be433d762b
commit 0da8cb2e02
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 6 deletions

View file

@ -0,0 +1,5 @@
---
bugfixes:
- filesize - add support for busybox dd implementation, that is used by default on Alpine linux
(https://github.com/ansible-collections/community.general/pull/4288,
https://github.com/ansible-collections/community.general/issues/4259).

View file

@ -83,7 +83,7 @@ options:
- Whether or not the file to create should be a sparse file. - Whether or not the file to create should be a sparse file.
- This option is effective only on newly created files, or when growing a - This option is effective only on newly created files, or when growing a
file, only for the bytes to append. file, only for the bytes to append.
- This option is not supported on OpenBSD, Solaris and AIX. - This option is not supported on OSes or filesystems not supporting sparse files.
- I(force=true) and I(sparse=true) are mutually exclusive. - I(force=true) and I(sparse=true) are mutually exclusive.
type: bool type: bool
default: false default: false
@ -129,6 +129,10 @@ seealso:
- name: dd(1) manpage for NetBSD - name: dd(1) manpage for NetBSD
description: Manual page of the NetBSD's dd implementation. description: Manual page of the NetBSD's dd implementation.
link: https://man.netbsd.org/dd.1 link: https://man.netbsd.org/dd.1
- name: busybox(1) manpage for Linux
description: Manual page of the GNU/Linux's busybox, that provides its own dd implementation.
link: https://www.unix.com/man-page/linux/1/busybox
''' '''
EXAMPLES = r''' EXAMPLES = r'''
@ -377,12 +381,10 @@ def complete_dd_cmdline(args, dd_cmd):
return list() return list()
bs = args['size_spec']['blocksize'] bs = args['size_spec']['blocksize']
conv = list()
# For sparse files (create, truncate, grow): write count=0 block. # For sparse files (create, truncate, grow): write count=0 block.
if args['sparse']: if args['sparse']:
seek = args['size_spec']['blocks'] seek = args['size_spec']['blocks']
conv += ['sparse']
elif args['force'] or not os.path.exists(args['path']): # Create file elif args['force'] or not os.path.exists(args['path']): # Create file
seek = 0 seek = 0
elif args['size_diff'] < 0: # Truncate file elif args['size_diff'] < 0: # Truncate file
@ -394,8 +396,6 @@ def complete_dd_cmdline(args, dd_cmd):
count = args['size_spec']['blocks'] - seek count = args['size_spec']['blocks'] - seek
dd_cmd += ['bs=%s' % str(bs), 'seek=%s' % str(seek), 'count=%s' % str(count)] dd_cmd += ['bs=%s' % str(bs), 'seek=%s' % str(seek), 'count=%s' % str(count)]
if conv:
dd_cmd += ['conv=%s' % ','.join(conv)]
return dd_cmd return dd_cmd

View file

@ -29,7 +29,6 @@
include_tasks: sparse.yml include_tasks: sparse.yml
when: when:
- not (ansible_os_family == 'Darwin' and ansible_distribution_version is version('11', '<')) - not (ansible_os_family == 'Darwin' and ansible_distribution_version is version('11', '<'))
- not (ansible_os_family == 'Alpine') # TODO figure out why it fails
- name: Include tasks to test playing with symlinks - name: Include tasks to test playing with symlinks
include_tasks: symlinks.yml include_tasks: symlinks.yml