Andrew Gaul
a568aa70fd
Replace uses of emplace with operator=(&&) ( #2287 )
...
emplace does not overwrite the value if the key already exists. C++17 has
insert_or_assign but C++11 only has operator= which invokes the default
constructor. Follows on to 6781ef5bd1
.
2023-08-22 23:12:12 +09:00
Takeshi Nakatani
218adcb29b
Fixed errors in cache.cpp from cppcheck 2.11.1 ( #2286 )
2023-08-20 19:00:20 +09:00
Andrew Gaul
8d04ee3e01
Own values in stat_cache and symlink_cache ( #2284 )
...
This removes an unnecessary use of unique_ptr.
2023-08-20 12:10:47 +09:00
Andrew Gaul
b2bb12fd2c
Remove unneeded explicit std::string constructors ( #2273 )
...
std::string(const char*) implicitly constructs these. The remaining call sites
requires string literals from C++14.
2023-08-17 22:12:28 +09:00
Andrew Gaul
e157d811cb
Use std::string::compare and operator== where possible ( #2256 )
2023-08-15 21:22:36 +09:00
Andrew Gaul
56a4e67009
Replace more raw pointers with std::unique_ptr ( #2255 )
2023-08-14 00:03:10 +09:00
Andrew Gaul
b29f8d0f2b
Use C++ enum class for most enums ( #2241 )
...
This promotes type-safety.
2023-07-30 22:53:17 +09:00
Andrew Gaul
36db898d01
Use C++11 std::map::erase return value ( #2236 )
2023-07-27 23:34:43 +09:00
Andrew Gaul
a4a2841c05
Use C++11 nullptr instead of 0 or NULL ( #2234 )
...
This improves type-safety.
2023-07-27 21:56:58 +09:00
Takeshi Nakatani
faec0d9d15
Refixed for cppcheck 2.1x
2023-07-26 07:55:33 +09:00
Garen Chan
9d00b8d4a8
Fixed segmentation fault caused by file write failure ( #2123 )
2023-03-11 16:45:56 +09:00
Andrew Gaul
0ba49518e9
Make some methods and parameters const ( #2078 )
...
This requires making some locks mutable.
2023-01-04 20:23:39 +09:00
Takeshi Nakatani
c491fbeabc
Replace uses of lock_already_held flag with AutoLock::Type
2022-07-30 16:20:43 +09:00
Andrew Gaul
48e9e51f4f
Remove more unneeded headers identified by IWYU ( #2011 )
2022-07-30 12:06:47 +09:00
Takeshi Nakatani
4b2f3fecb5
Set mtime/ctime/atime of all objects as nanosecond
2022-07-28 13:47:03 +09:00
Takeshi Nakatani
ec7810f08e
Fixed a bug could not change the mode while the file was opened
2022-06-12 13:48:42 +09:00
Andrew Gaul
5c57e17b77
Enable noobj_cache by default ( #1922 )
...
This should improve performance in many situations. s3fs already
enables the stat cache by default so memorizing noobj makes this more
consistent. Fixes #1901 .
2022-03-12 16:57:31 +09:00
Andrew Gaul
8a5c4306f5
Preserve sub-second precision where possible ( #1915 )
2022-02-23 23:58:51 +09:00
Takeshi Nakatani
e452ef3940
Fixed the fault tolerance when time stamp getting fails
2022-01-30 18:31:36 +09:00
Andrew Gaul
cd5a69b9eb
Handle UTIME_NOW and UTIME_OMIT special values ( #1868 )
...
FUSE 3 will require this behavior. References #1159 .
2022-01-29 11:35:37 +09:00
Andrew Gaul
662882d2f0
Always call clock_gettime(2) ( #1871 )
...
e01ded9e27
introduced this compatibility
shim but macOS 10.12 (2016) added this:
https://stackoverflow.com/a/39801564 . Also remove fallback to
time(3) which loses precision.
2022-01-25 08:36:27 +09:00
Andrew Gaul
7638b5b3e3
Prefer std::string::rbegin over operator[] ( #1673 )
...
This is more concise and safer due to not repeating the variable name.
We cannot use std::string::back since it is not available in C++03.
2021-06-13 13:26:38 +09:00
Takeshi Nakatani
b5fef788da
Additional bug fixing for not creating zero-byte object
2021-05-09 17:33:53 +09:00
Andrew Gaul
d904d91252
Prefer std::map::insert over find and operator[] ( #1653 )
...
This avoids a duplicate lookups.
2021-05-09 14:11:35 +09:00
Andrew Gaul
7f3e423bbe
Preserve sub-second time precision ( #1624 )
...
Found via pjdfstests. References #897 . References #1589 .
2021-04-18 13:11:12 +09:00
林千里
22b0ae9d51
set IsExpireTime to true by default
...
fixes #1563
2021-02-12 12:20:47 +09:00
Andrew Gaul
d019dda4f7
Simplify substr manipulations with erase ( #1532 )
...
This avoids creating a new std::string.
2021-01-25 18:02:32 +09:00
Andrew Gaul
b0e8758b63
Use result instead of res for consistency ( #1530 )
2021-01-25 07:56:10 +09:00
Takeshi Nakatani
059cc57ba6
Added atime and Corrected atime/mtime/ctime operations
2020-10-04 13:54:01 +09:00
Andrew Gaul
503c86bb8a
Call is_prefix instead of compare and substr
2020-09-27 22:19:54 +09:00
Andrew Gaul
1043e08dfa
Remove uses of implicit namespace std
...
Fixed via:
sed -i '/using namespace std/{N;d}' src/*.cpp
sed -i 's/ string/ std::string/g' src/*.cpp
sed -i 's/(string/(std::string/g' src/*.cpp
sed -i 's/\[string/\[std::string/g' src/*.cpp
sed -i 's/^string/std::string/g' src/*.cpp
sed -i 's/ ifstream/ std::ifstream/g' src/*.cpp
sed -i 's/ istringstream/ std::istringstream/g' src/*.cpp
sed -i 's/ ostringstream/ std::ostringstream/g' src/*.cpp
sed -i 's/ max(/ std::max(/g' src/*.cpp
sed -i 's/ min(/ std::min(/g' src/*.cpp
sed -i 's/ endl/ std::endl/g' src/*.cpp
2020-09-13 11:57:20 +09:00
Takeshi Nakatani
b5ffd419d8
Source file division and set 4 spaces and cleanup
2020-08-26 17:43:50 +09:00
Andrew Gaul
1ec8528502
Add const where possible
...
Found via cppcheck 2.1
2020-08-20 23:46:11 +09:00
Andrew Gaul
958ad83a4b
Correct vim modeline to 2-space indentation
2020-08-19 21:03:46 +09:00
Andrew Gaul
0fbd0eac80
Change default stat_cache_expire
...
Previously s3fs cached files forever which confused users with
creating objects using another client.
2020-07-26 23:04:43 +09:00
Andrew Gaul
40f7007263
Check results from pthread mutex calls
...
Also remove some unnecessary exception handling.
2020-05-30 16:37:55 +09:00
Takeshi Nakatani
c44a60f3f5
Fixed a bug of stats cache compression
2020-04-12 18:33:00 +09:00
Andrew Gaul
56141557dc
Avoid unneeded string copy
...
Found by clang-tidy 10.
2020-03-28 08:49:49 +09:00
Takeshi Nakatani
23945a0130
In memory cache for softlinks with cache out
2020-01-13 20:23:10 +09:00
Takeshi Nakatani
bedd648d47
Fixed build error by cppcheck 1.89
2019-09-23 10:49:49 +00:00
Andrew Gaul
f528a86219
Pass lock_already_held state to DelStat
2019-08-01 11:07:56 -07:00
Andrew Gaul
ffac4c8417
Avoid narrowing time_t and off_t args in logging
...
This displays correct results on 32-bit platforms.
2019-07-14 17:02:36 -07:00
Takeshi Nakatani
d39e4e4b1f
Merge pull request #1087 from gaul/clang-tidy/deprecated-headers
...
Prefer modern C headers
2019-07-15 03:50:15 +09:00
Andrew Gaul
6fd42d9fe4
Prefer modern C headers
...
Found and fixed via clang-tidy.
2019-07-12 03:50:59 -07:00
Andrew Gaul
a83d5baa90
Remove recursive locking
...
Recursive locking is frowned upon and is incompatible with
PTHREAD_MUTEX_ERRORCHECK. Also clean up pthread_mutex_lock error
checking.
2019-07-10 12:39:00 -07:00
Andrew Gaul
c596441f58
Flush file when opening second fd
...
Previously when s3fs had dirty local data and an application opened a
second fd it would remove the stat cache entry, query S3 for the size
which was still zero, then reinitialize FdEntry with this incorrect
size. Instead flush local data to S3 so this query works. It is
possible that a more involved patch could do this with a less
heavyweight approach but this requires changing open. This does not
completely fix git clone but allows it to proceed further. Also make
some cache methods const-correct. References #839 .
2019-07-02 01:12:09 -07:00
Andrew Gaul
4d0bef1e90
Clear containers instead of individual erases
...
This has O(n) runtime instead of O(n log n).
2019-02-02 23:58:43 -08:00
Andrew Gaul
35d55ee513
Remove unneeded void parameter
...
This is implicit in C++. Found and fixed via clang-tidy.
2019-01-28 23:22:27 -08:00
Takeshi Nakatani
a0c1f30ae7
Merge pull request #932 from gaul/autolock
...
Prefer AutoLock for synchronization
2019-01-27 15:59:18 +09:00
Andrew Gaul
92d3114584
Prefer AutoLock for synchronization
...
This simplifies the code and fixes an issue with unlocked access.
Also use a recursive lock for StatCache to avoid races between
lock..unlock..lock sequences.
2019-01-25 15:28:41 -08:00