- len must not be <= 0
- offset + len must not exceed off_t (max. file size)
Fixes: 7636b58590 ("* autoload.cc (NtSetInformationFile): Define.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Upstream GCC changed -Wimplicit-function-declaration warning into an
error. The build break about missing fpclassifyf function prototype
exposed a bug in the PRU port of libm.
The fix is to use the fpclassify macro for both double and float types.
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
Upstream GCC has change this warning into error by default, so...we need
to explicitly convert the type from pointer from/to integer, generally
it's unsafe, but we know what we are doing here.
However it's not safe for ilp32 on RV64, but we didn't support that yet, so I
think this fix is good enough now :)
The out pointer is only used if data_chunk_count is > 0,
so there's no reason to set it to NULL in the error case.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
In cases where malloc fails for the 'g->matchjump' allocation, the code
path does not handle the failure gracefully, potentially leading to a
memory leak. This fix ensures proper cleanup by freeing the allocated
memory for 'pmatches' before returning.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Given that SSDs don't have a seek penalty, we can enable
automatic sparsifying of files on SSDs, even if the "sparse"
mount option is not set.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
In preparation of using the FileFsSectorSizeInformation info class,
add a couple of missing definitions.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Commit a3ae2a7348 ("Cygwin: don't autoload some kernel32 functions")
erroneously removed DiscardVirtualMemory from the list of autloaded
functions. DiscardVirtualMemory is not available on Windows 8.1.
Fixes: a3ae2a7348 ("Cygwin: don't autoload some kernel32 functions")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Replace multiplication with division for microseconds calculation from
nanoseconds in _gettimeofday function.
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
We've been manually editing newlib.hin after generating it with
autoheader to drop the version defines that we keep in the separate
_newlib_version.h header. This is confusing for people, and is an
easy source of mistakes/errors.
Since we're already running sed on newlib.h during configure to
filter out defines we don't want to expose, add the version macros
there too. This way we don't have to manually edit newlib.hin.
This simplifies the autoreconf step in exchange for a slightly more
complicated configure+sed step, but seems worth the trade-off.
Split fhandler_disk_file::fallocate into multiple methods, each
implementing a different aspect of fallocate(2), thus adding
FALLOC_FL_PUNCH_HOLE and FALLOC_FL_ZERO_RANGE handling.
For more correctly implementing posix_fallocate(3) semantics, make
sure to re-allocate holes in the given range if the file is sparse.
While at it, change the way checking when to make a file sparse.
The rule is now, make file sparse if the hole created by the action
spans at least one sparse block, taking the allocation granularity
of sparse files into account.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
write(2) sparsifies a file after an lseek far enough beyond EOF.
Let pwrite(2) sparsify as well if offset is far enough beyond EOF.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
fallocate is not supposed to return an errno code, it has to
return -1 and set errno.
Fixes: dd90ede40510 ("Cygwin: introduce fallocate(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
open(2) implements O_TRUNC by just reducing the size of the file
to 0, to make sure EAs stay available.
Turns out, file sparseness is not removed this way either, so add
code to do just that.
Fixes: 603ef545bd ("* fhandler.cc (fhandler_base::open): Never open files with FILE_OVERWITE/FILE_OVERWRITE_IF.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
First cut of the new, Linux-specific fallocate(2) function.
Do not add any functionality yet, except of basic handling
of FALLOC_FL_KEEP_SIZE.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
also, take mode flags parameter instead of just a bool.
Introduce __FALLOC_FL_TRUNCATE mode flag as internal flag to
indictae being called from ftruncate(2).
This is in preparation of an upcoming change introducing the
Linx-specific fallocate(2) call.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The fhandler method ftruncate returns either EISDIR if it has been
called on directories, or EINVAL if called on files other than
regular files. This matches what ftruncate(2) is supposed to return,
but it doesn't match posix_fallocate(3), which is supposed to return
ENODEV in both cases.
To accomplish that, return ENODEV from fhandler_base::ftruncate()
and convert it to EINVAL in ftruncate(2). In posix_fallocate(3),
convert EISDIR to ENODEV.
Fixes: 7636b58590 ("* autoload.cc (NtSetInformationFile): Define.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The code introducing the lseek(2) code for the GNU extensions
SEEK_DATA and SEEK_HOLE accidentally checks if the mount point
has the "sparse" flag set and, if not, emulates SEEK_DATA/SEEK_HOLE
per the Linux specs.
However, the mount point "sparse" flag only determines whether
files should be made sparse or not. Files may be sparse independently
of that, obviously.
Fix that by checking for the FILE_ATTRIBUTE_SPARSE_FILE attribute
instead.
Fixes: edfa581d3c ("Cygwin: lseek: implement SEEK_DATA and SEEK_HOLE for files")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Previously, e.g. nl_langinfo(_NL_TIME_WMONTH_1) returns "February"
due to the bug. Similarly, nl_langinfo(_NL_TIME_WWDAY_1) returns
"Mon". This occurs because wide char month and weekday arrays are
pointed off-by-one (e.g. the array wmon[12] is reffered as wmon[1-12]
rather than wmon[0-11]). This patch fixes that.
Fixes: d47d5b850b ("Extend locale support to maintain wide char values of native strings")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
No longer drop ranges of identical link names. Append '#0, #1, ...'
to each name instead. Enhance charset allowed in label names.
No longer ignore null volume serial numbers.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
Now that the low-level functions set and test stream orientation,
a few calls in API functions are redundant.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This allows to set and test orientation correctly if input is only
using macros from stdio.h. Wide-char-oriented functions must call
__srefill_r directly.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Introduce function __swbufw_r and macros/inline-functions called
__swputc_r. Call these functions/macros exclusively from wide-char
functions.
This allows to set and test the stream orientation correctly even if
output is only performed using byte-oriented macros from stdio.h.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The commit 3d94e07c49 has a few bugs which cause testsuite failure
in libstdc++. This is due to excess orientation check in __srefill_r()
and _ungetc_r(). Further, sscanf() family also calls ssvfscanf() family
with fp->_file == -1. This causes undesired orientation set/check for
sscanf() family. This patch fixes these problems.
Also, as in GLibC, do not set orientation in ungetc, and only set, but
do not check orientation in ungetwc.
Fixes: 3d94e07c49 ("newlib: libc: Fix crash on fprintf to a wide-oriented stream.")
Reported-by: Christophe Lyon <christophe.lyon@linaro.org>
Reported-by: Joel Sherrill <joel@rtems.org>
Co-developed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The _REENT_MP_P5S blocks are allocated using Balloc via i2b and linked in the
pow5mult call. As a result these blocks are not on the freelist managed by the
Bfree call. This change fixes a memory leak in threads that clean up using
_reclaim_reent.
RTEMS: Closes#4967
The new directories '/dev/disk/by-label' and '/dev/disk/by-uuid'
provide symlinks for each disk related volume label and serial
number:
'VOLUME_LABEL' -> '../../sdXN'
'VOLUME_SERIAL' -> '../../sdXN'
Signed-off-by: Christian Franke <christian.franke@t-online.de>
__sfvwrite_r is called under lock. There's no reason to call
putc, locking the file recursively. Add a comment that locking
is required when calling __sfvwrite_r.
Fixes: 49d64538cd ("* libc/include/stdio.h (FILE): define __SCLE for "convert line endings" for Cygwin.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
So far, the printf family of functions has two output helper functions
called __sprint_r and __sfputs_r. Both are called from all variants of
vfprintf as well as vfwprintf. There are also analogue helper functions
for the string-creating functions vsprintf/vswprintf called __ssprint_r
and __ssputs_r.
However, the helpers are built once when building vfprintf/vsprintf with
the INTEGER_ONLY flag, and then they are part of the vfiprintf.c and
vsiprintf.c files.
The problem is this:
Even if a process only calls vfwprintf or the non-INTEGER_ONLY vfprintf
it will always have to include the INTEGER_ONLY vfiprintf. Otherwise the
helper functions are undefined. Analogue for the string-creating
functions.
That's a useless waste of space by including one (or two) big, unused
function, if newlib is linked in statically.
Create new files to define the printf output helpers separately and
split them into byte-oriented and wide-char-oriented functions. This
allows to link only the required functions.
Also, simplify the string output helpers and fix a potential (but
unlikely) buffer overflow in __ssprint_r.
Fixes: 8a0efa53e4 ("import newlib-2000-02-17 snapshot")
Fixes: 6121968b19 ("* libc/include/stdio.h (__VALIST): Guard against multiple definition.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The last two patches to configure.ac missed regeneration of newlib.hin.
Fixes: 64a11fded1 ("Fix problem with _newlib_version.h not being filled in correctly")
Fixes: 39f734a857 ("newlib: fix AC_DEFINE quoting style with version macros")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The new directory '/dev/disk/by-drive' provides symlinks for each
disk related drive letter:
'x' -> '../../sdXN'
The new directory '/dev/disk/by-voluuid' provides symlinks for each
disk related storage volume:
'MBR_SERIAL-OFFSET' -> '../../sdXN'
'VOLUME_GUID' -> '../../sdXN'
Both directories provide Windows specific information and do not
exist on Linux.
Signed-off-by: Christian Franke <christian.franke@t-online.de>
This makes rand(3) ISO C compliant and adds locking to avoid
race conditions.
Reported-by: Bruno Haible <bruno@clisp.org>
Fixes: 8a0efa53e4 ("import newlib-2000-02-17 snapshot")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Minor updates to profiler and gmondump, which share some code:
- fix operation of error() so it actually works as intended
- resize 4K-size auto buffer reservations to BUFSIZ (==1K)
- remove trailing '\n' from 2nd arg on error() calls everywhere
- provide consistent annotation of Windows error number displays
Fixes: 9887fb27f6126 ("Cygwin: New tool: profiler")
Fixes: 087a3d76d7335 ("Cygwin: New tool: gmondump")
Signed-off-by: Mark Geisert <mark@maxrnd.com>
Add locking to the random(3) family of functions to gain
thread-safety per POSIX. Use NetBSD version of the file as
role-model.
Reported-by: Bruno Haible <bruno@clisp.org>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Previously, fprintf() on a wide-oriented stream crashes or outputs
garbage. This is because a narrow char string which can be odd bytes
in length is cast into a wide char string which should be even
bytes in length in __sprint_r/__sfputs_r based on the __SWID flag.
As a result, if the length is odd bytes, the reading buffer runs over
the buffer length, which causes a crash. If the length is even bytes,
garbage is printed.
With this patch, any output to the stream which is set to different
orientation fails with error just like glibc. Note that it behaves
differently from other libc implementations such as BSD, musl and
Solaris.
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>