1
0
mirror of https://github.com/facebook/zstd.git synced 2025-07-04 07:42:31 +03:00
Commit Graph

183 Commits

Author SHA1 Message Date
4d6c78fb89 Only set numPhysicalCores if ratio is valid 2021-03-03 10:59:00 +11:00
eb1a09df61 If cpuinfo parsing fails fallback to sysconf 2021-03-03 10:58:51 +11:00
61db590ad8 Detect .. in Paths Correctly
This commit addresses #2509.
2021-02-26 12:29:42 -05:00
a774c57973 Use umask() to Constrain Created File Permissions
This commit addresses #2491.

Note that a downside of this solution is that it is global: `umask()` affects
all file creation calls in the process. I believe this is safe since
`fileio.c` functions should only ever be used in the zstd binary, and these
are (almost) the only files ever created by zstd, and AIUI they're only
created in a single thread. So we can get away with messing with global state.

Note that this doesn't change the permissions of files created by `dibio.c`.
I'm not sure what those should be...
2021-02-17 15:27:39 -05:00
66e811d782 [license] Update year to 2021 2021-01-04 17:53:52 -05:00
fed1c62571 fix gcc10 warnings
gcc10 doesn't like its own strncpy
2020-11-30 04:44:37 -08:00
02422db841 Fix Stdin typo 2020-09-25 11:51:35 -04:00
88f4410390 Add more useful failure message when stdin is an input 2020-09-24 16:29:12 -04:00
93d63eaeb8 Expand UTIL_requireUserConfirmation to include stdin input check 2020-09-24 15:58:06 -04:00
0e8ac6b995 Add fCtx to FIO_openDstFile() 2020-09-24 15:49:30 -04:00
7aa3da1cd7 Use IS_CONSOLE macro to detect that we're indeed using a console 2020-09-22 14:15:52 -04:00
7991c55181 Move logic into new function FIO_removeMultiFilesWarning, add support for decompression 2020-08-26 16:50:20 -04:00
aab11ce3db Unified warning prompts into new function UTIL_requireUserConfirmationToProceed() 2020-08-25 11:25:49 -04:00
51ac0207af Remove UTIL_statFile() and UTIL_statDir(); Decompose Former Call-Sites 2020-08-10 15:28:02 -04:00
93dda988c8 Remove Unused Function UTIL_fileExist() 2020-08-10 15:22:53 -04:00
c1449143c5 Share stat() Calls in Uses of UTIL_chmod() 2020-08-05 12:10:42 -04:00
0a8aacb4db Use stat() to Check that File Should be chmod()-ed
Rather than special-casing a check for `/dev/null`, this uses `stat()` to
avoid `chmod()`-ing any non-regular file. I believe this is the desirable
behavior. `UTIL_chmod()` is never called on directories at the moment, only
output files.
2020-08-05 12:00:12 -04:00
7238cca1a1 Deduplicate Some Low-Hanging Fruit of Redundant Stat Calls 2020-08-05 01:08:34 -04:00
44fa052599 Introduce Variants of Various UTIL Functions that Take Pre-Populated stat_t Structs
Instead of calling `stat()`, these functions accept the result of a previous
`stat()` call on the file in question, which will allow us to make multiple
decisions around a file without redundant `stat()` calls.
2020-08-05 01:00:06 -04:00
b6e24bc4dc Rename UTIL_getFileStat() -> UTIL_statFile() and UTIL_getDirectoryStat() -> UTIL_statDir()
I want to introduce versions of many of these functions that take pre-
populated `stat_t` objects and use those rather than doing their own redundant
`stat()` internally. These functions will have `...Stat()` suffixes. So this
commit renames these existing functions into the active voice, to avoid
confusion.
2020-08-05 00:40:16 -04:00
1a1003f996 Mark stat_t Arg to UTIL_setFileStat() const 2020-08-05 00:35:21 -04:00
5fbc6addb6 Additionally Convert UTIL_getFileStat() Calls to UTIL_stat() Where Appropriate 2020-08-05 00:31:48 -04:00
69cb9e7798 Use New Stat Helper 2020-08-05 00:24:32 -04:00
b11bea56a5 Introduce Dedicated Helper to Call stat() 2020-08-05 00:21:21 -04:00
26d01bdb26 programs/util.c: fix build without st_mtime
Since version 1.4.5 and commit
5af8cb7aea, if st_mtime is not defined,
programs/util.c uses utime without including utime.h which will raise
the following build failure on some of the buildroot autobuilders:

util.c: In function 'UTIL_setFileStat':
util.c:161:24: error: storage size of 'timebuf' isn't known
         struct utimbuf timebuf;
                        ^~~~~~~

Fixes:
 - http://autobuild.buildroot.org/results/be902c5d110f37bce622a2215191f155b7d3e7e0

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2020-07-15 21:24:13 +02:00
9a8ccd4ba3 Add output-dir-mirror option 2020-06-24 22:12:11 -07:00
ac58c8d720 Fix copyright and license lines
* All copyright lines now have -2020 instead of -present
* All copyright lines include "Facebook, Inc"
* All licenses are now standardized

The copyright in `threading.{h,c}` is not changed because it comes from
zstdmt.

The copyright and license of `divsufsort.{h,c}` is not changed.
2020-03-26 17:02:06 -07:00
f6d00c059f [util] Fix readLineFromFile on Cygwin 2020-01-13 14:37:22 -08:00
d0dcaf56c2 Make UTIL_countPhysicalCores() work under Cygwin (#1941)
Cygwin currently uses the fallback implementation which just returns 1 every time,
which leads to bad performance when zstd is called with -T0 for example.

Instead use the POSIX implementation used for the BSDs which works just fine under Cygwin.

Tested under Cygwin and MSYS2.
2020-01-07 15:48:26 -08:00
5666835ea7 Add Comment 2019-12-23 13:24:28 -05:00
5af8cb7aea Use statbuf->st_mtim Again 2019-12-23 13:24:28 -05:00
a49417b5af fix recent issue combining -r with empty list of input files
This would resize the table of input filenames to zero,
delivering an empty table,
to which it was no longer possible to add stdin.
2019-12-02 14:28:18 -08:00
d5b4a7ea58 removed scanbuild workaround 2019-11-26 17:46:57 -08:00
96ee20758c assembleFNT() can no longer fail 2019-11-26 15:44:33 -08:00
aaab618ae9 pushed aside stdio.h too
since only UTIL_DISPLAY() depended on it.
2019-11-26 15:25:32 -08:00
7543cd055c moved UTIL_DISPLAY() inside util.c 2019-11-26 15:21:58 -08:00
a684b82774 util: isolated some dependencies
from *.h to *.c
so that they don't get transitively included
into users of util.h.
2019-11-26 15:16:53 -08:00
f622c0adf3 switched UTIL_refFilename() to an assert() 2019-11-26 14:48:23 -08:00
c71bd45a3b Merge branch 'dev' into ahmed_file 2019-11-26 11:20:26 -08:00
5e657aca90 silence scan-build false positive
blind attempt
2019-11-25 15:50:58 -08:00
9a3de0a535 changed name from createX to assembleX
shows that the resulting object just takes ownership of provided buffer.
2019-11-25 15:34:55 -08:00
9a22140ef4 created UTIL_chmod()
protecting "/dev/null" from having its permissions changed.

also : minor : improved consistency of util.h API
2019-11-25 13:45:22 -08:00
612a06eb3e Update util.c 2019-11-19 23:24:00 +03:00
f62cf1fff5 Fix typo in util.c
There must be mtim*e*
2019-11-19 23:15:28 +03:00
9df49dc50a Visual compiler bug work-around 2019-11-06 15:23:44 -08:00
a7e33e3e10 updated fuzz tests to use FileNamesTable* abstraction 2019-11-06 14:42:13 -08:00
31a0abbfda updated pzstd and largeNbDicts to use the new FileNamesTable* abstraction 2019-11-06 09:10:05 -08:00
b09f59390b refactor code to only use FileNamesTable* 2019-11-05 17:02:43 -08:00
76b9e42b0b refactoring (simplification) of util.h public API 2019-11-05 14:59:45 -08:00
81c51483e9 Merge branch 'dev' into ahmed_file 2019-11-05 14:44:12 -08:00