We have already automakes's automatic dependencies like
bla.h.in -> bla.h -> foo.o -> bar.la
An explicit direct dependency bla.h.in -> bar.la
is redundant and useless anyways.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Headers should only be listed in either *_HEADERS or
*_SOURCES, especially when we want nodist_*_HEADERS.
Since all the generated headers are made by configure we
don't even need to use BUILT_SOURCES or other tricks.
Also see automake docs 9.4.1 Built Sources Example:
case "Build bindir.h from configure"
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Let's make it possible to use debug.h without environment variables.
Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing
* use __UL_DEBUG_FL_NOADDR when SUID
* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
to provide access to the current mask from ul_debugobj(). It's better
than modify all ul_debugobj() calls and use the global mask as
argument.
* remove never used UL_DEBUG_DEFINE_FLAG
Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
* set whole_disk variable if SUN_TAG_WHOLEDISK specified
* fix N-1 bug in add new partition according to template (script)
Addresses: https://github.com/karelzak/util-linux/issues/555
Signed-off-by: Karel Zak <kzak@redhat.com>
Made gpt_entry_set_name() return number of utf8 bytes processed on
success, so info message about change can be accurate.
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Allocate 3*number_of_ucs2_characters bytes for utf8 output.
Also as we are using calloc there's no need to write terminating null
byte.
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
GPT partition name entry should be recorded as little endian UCS2, so I have
written proper conversion (assuming UTF8 input).
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Potential partition start should be aligned to cylinders. So fdisk
wouldn't consider partition's last cylinder remains as eligible space
for new partition start.
Without this, 'sfdisk -d' with certain filenames would lead to
reading an 's' from the 'type' field in fdisk_reset_labelitem
and cause a crash due to prematurely freeing the 'data.str' field.
Signed-off-by: Roddy Shuler <roddy@endlessm.com>
sun_add_partition() allowed the 1st sector to be 0 for the 3rd partition
only if that sector was free or if other partitions covered the whole
disk. Now it's always allowed for the 1st sector to be set to 0 for
the 3rd partition.
[kzak@redhat.com: - print info about "wholedisk" before "First sector" dialog for 3rd partition
- default to 0 for 3rd partition start sector]
Signed-off-by: Mikhail Vorobyov <m.vorobyov@cs.msu.ru>
Signed-off-by: Karel Zak <kzak@redhat.com>
Fixes one leak and one unchecked allocation error.
[kzak@redhat.com: - don't call fdisk_ask_menu_get_result()
after failed fdisk_do_ask()]
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's provide API for applications that don't want to use the default
1MiB grain. The new function allow to use "as minimal as possible" if
grain is set by fdisk_save_user_grain() to 512.
If the phy sector size (or minimal I/O size) is greater than specified
grain size than smallest possible setting is used.
Signed-off-by: Karel Zak <kzak@redhat.com>
If partition does not require alignment, then don't call LBA align
function and don't use size-=1 (fdisk_align_lba_in_range() returns
unmodified size and we call size=-1 more than once for the same size).
Signed-off-by: Karel Zak <kzak@redhat.com>
* disable dialogs for the mkpart sample
* add --nopartno use-case to force libfdisk to use default partno(s)
* add test for this feature
Signed-off-by: Karel Zak <kzak@redhat.com>
The current code assumes that partition offsets (starts) are sorted.
This is usual situation, but unsorted partition table is also valid...
Signed-off-by: Karel Zak <kzak@redhat.com>
The default (for historical reasons) is to use dialog driven partitioning.
It's possible to avoid dialogs by fdisk_partition template for
fdisk_add_partition().
Unfortunately in some case (mostly DOS driver) it's not enough, because
we need to distinguish between logical and primary partitions. If we know
that dialogs are unwanted then we can default to primary partition, etc.
This function simplify semantic of the library for non-interactive
programs.
Signed-off-by: Karel Zak <kzak@redhat.com>
The PMBR partition record should be StartingCHS=0x002000 (0/0/2)
and EndingCHS=0xFFFFFF (1023/255/63)
Addresses: https://github.com/karelzak/util-linux/issues/485
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch introduces fdisk_reread_changes(). The function is
less invasive alternative to fdisk_reread_partition_table().
The new function uses BLKPG ioctls for modified partitions. The
another partitions are not affected. This solution allows to
successfully use fdisks on disk where some partitions are still use
(mounted). For example if you want to resize the last partition on the
device.
Signed-off-by: Karel Zak <kzak@redhat.com>
This stupid bug has been introduced by e1cfb304 (v2.30) and it
disables to create extended partition by cfdisk :-(
Signed-off-by: Karel Zak <kzak@redhat.com>
clang issued warnings like this:
../libfdisk/src/gpt.c:371:18: warning: taking address of packed member 'type' of class or structure 'gpt_entry' may result in an unaligned pointer value [-Waddress-of-packed-member]
guid_to_string(&e->type, str);
^~~~~~~
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We are using now the formerly unused function sun_pt_checksum(). This
cleanup was motivated by clang compiler warning, see below. Also nice
that we are now always using uint16_t instead of short.
Warning was:
../libfdisk/src/sun.c:177:35: warning: taking address of packed member 'csum' of class or structure 'sun_disklabel' may result in an unaligned pointer value
[-Waddress-of-packed-member]
while(ush < (unsigned short *)(&sunlabel->csum))
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We got some errors on Alpine Linux where $LTLIBINTL is non-empty:
./.libs/libcommon.a(libcommon_la-blkdev.o): In function `open_blkdev_or_file':
lib/blkdev.c:282: undefined reference to `libintl_gettext
collect2: error: ld returned 1 exit status
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
libfdisk/src/context.c: In function 'fdisk_assign_device':
libfdisk/src/context.c:549:7: warning: declaration of 'rc' shadows a previous local [-Wshadow]
libfdisk/src/context.c:542:10: note: shadowed declaration is here
[kzak@redhat.com: - add rc to debug message]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
The current libfdisk code uses gettext() to translate strings. It
means it follows the default text domain (as set by textdomain(3)
usually in the main program). This is useless for public shared
library.
We have call private bindtextdomain() and use dgettext() with private
domain name to be independent on the main program. For this purpose
include/nls.h supports UL_TEXTDOMAIN_EXPLICIT to use dgettext().
Note that libfdisk will continue to use util-linux.po, rather than
keep the texts in the separate file.
The nls.h has to be included only from fdiskP.h to be sure that
nls.h works as expected for the library.
Signed-off-by: Karel Zak <kzak@redhat.com>
read(2) behavior is undefined if you want to read more than SSIZE_MAX
bytes. Let's be paranoid and check for this...
Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
If possible use size_t for number of entries (partitions). It
makes code more readable and without unnecessary casts.
Signed-off-by: Karel Zak <kzak@redhat.com>
We blindly assume that our sizeof(struct gpt_entry) is the same
on-disk stored header->sizeof_partition_entry.
It seems more correct would be to use sizeof specified by header to
access the entries array items. This patch introduces gpt_get_entry()
to avoid direct access to gpt->ents[].
Signed-off-by: Karel Zak <kzak@redhat.com>
* '2017wk11' of git://github.com/kerolasa/lelux-utiliteetit:
blkid: add control struct
blkid: simplify version option handling
tests: add static keyword where needed [smatch scan]
tests: do not use plain 0 as NULL [smatch scan]
libsmartcols: fix test variable shadowing