summaryrefslogtreecommitdiff
path: root/src/posix.c
Commit message (Collapse)AuthorAgeFilesLines
* refactor: `src` is now `src/libgit2`Edward Thomson2022-02-221-303/+0
|
* path: separate git-specific path functions from utilEdward Thomson2021-11-091-3/+3
| | | | | | Introduce `git_fs_path`, which operates on generic filesystem paths. `git_path` will be kept for only git-specific path functionality (for example, checking for `.git` in a path).
* tests: optional test for p_open() with empty path segmentsPeter Pettersson2021-08-081-0/+7
|
* Support build with NO_MMAP to disable use of system mmapDhruva Krishnamurthy2020-12-301-5/+27
| | | | | * Use pread/pwrite to avoid updating position in file descriptor * Emulate missing pread/pwrite on win32 using overlapped file IO
* Remove broken support for write in emulated mmapDhruva Krishnamurthy2020-12-271-5/+6
| | | | | | | * Emulated mmap based write without pagefault handling is not possible since IO happens outside of call to mmap and data is written to mapped memory * Potential emulation using userfaultfd() might be possible
* posix: use GIT_ASSERTEdward Thomson2020-11-271-3/+4
|
* mmap: use a 64-bit signed type `off64_t` for mmapEdward Thomson2019-11-251-1/+1
| | | | Prefer `off64_t` to `git_off_t` for internal visibility.
* posix: fix direct use of `malloc`Patrick Steinhardt2019-08-231-6/+6
| | | | | | | | In "posix.c" there are multiple callsites which execute `malloc` instead of `git__malloc`. Thus, users of library are not able to track these allocations with a custom allocator. Convert these call sites to use `git__malloc` instead.
* posix: remove `p_fallocate` abstractionPatrick Steinhardt2019-06-141-38/+0
| | | | | | | | | | | | | | | By now, we have repeatedly failed to provide a nice cross-platform implementation of `p_fallocate`. Recent tries to do that escalated quite fast to a set of different CMake checks, implementations, fallbacks, etc., which started to look real awkward to maintain. In fact, `p_fallocate` had only been introduced in commit 4e3949b73 (tests: test that largefiles can be read through the tree API, 2019-01-30) to support a test with large files, but given the maintenance costs it just seems not to be worht it. As we have removed the sole user of `p_fallocate` in the previous commit, let's drop it altogether.
* NetBSD < 7 doesn't have posix_fallocateJacques Germishuys2019-05-241-1/+1
| | | | See: https://www.netbsd.org/changes/changes-7.0.html
* p_fallocate: compatibility fixes for macOSEdward Thomson2019-02-221-1/+22
| | | | | | | | | | | | | On macOS, fcntl(..., F_PREALLOCATE, ...) will only succeed when followed by an ftruncate(), even when it reports success. However, that syscall will fail when the file already exists. Thus, we must ignore the error code and simply let ftruncate extend the size of the file itself (albeit slowly). By calling ftruncate, we also need to prevent against file shrinkage, for compatibility with posix_ftruncate, which will only extend files, never shrink them.
* p_fallocate: don't duplicate definitions for win32Edward Thomson2019-02-221-17/+17
|
* tests: test that largefiles can be read through the tree APIEtienne Samson2019-01-301-0/+17
|
* git_error: use new names in internal APIs and usageEdward Thomson2019-01-221-3/+3
| | | | | Move to the `git_error` name in the internal API for error-related functions.
* Make sure to always include "common.h" firstPatrick Steinhardt2017-07-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | Next to including several files, our "common.h" header also declares various macros which are then used throughout the project. As such, we have to make sure to always include this file first in all implementation files. Otherwise, we might encounter problems or even silent behavioural differences due to macros or defines not being defined as they should be. So in fact, our header and implementation files should make sure to always include "common.h" first. This commit does so by establishing a common include pattern. Header files inside of "src" will now always include "common.h" as its first other file, separated by a newline from all the other includes to make it stand out as special. There are two cases for the implementation files. If they do have a matching header file, they will always include this one first, leading to "common.h" being transitively included as first file. If they do not have a matching header file, they instead include "common.h" as first file themselves. This fixes the outlined problems and will become our standard practice for header and source files inside of the "src/" from now on.
* Convert port with htons() in p_getaddrinfo()Ian Douglas Scott2017-06-231-1/+1
| | | | `sin_port` should be in network byte order.
* odb_loose: fsync testsEdward Thomson2017-02-281-0/+2
| | | | | | | Introduce a simple counter that `p_fsync` implements. This is useful for ensuring that `p_fsync` is called when we expect it to be, for example when we have enabled an odb backend to perform `fsync`s when writing objects.
* giterr_set: consistent error messagesEdward Thomson2016-12-291-1/+1
| | | | | | | | Error messages should be sentence fragments, and therefore: 1. Should not begin with a capital letter, 2. Should not conclude with punctuation, and 3. Should not end a sentence and begin a new one
* Split the page size from the mmap alignmentcmn/pool-limitCarlos Martín Nieto2016-03-161-0/+7
| | | | | | | | While often similar, these are not the same on Windows. We want to use the page size on Windows for the pools, but for mmap we need to use the allocation granularity as the alignment. On the other platforms these values remain the same.
* Copy into the correct destination.Sebastian Bauer2015-12-311-1/+1
|
* Bail out early when no memory is available.Sebastian Bauer2015-12-311-1/+4
|
* p_read: ensure requested len is ssize_tEdward Thomson2015-02-121-1/+11
| | | | | Ensure that the given length to `p_read` is of ssize_t and ensure that callers test the return as if it were an `ssize_t`.
* Merge commit 'refs/pull/2366/head' of github.com:libgit2/libgit2Carlos Martín Nieto2014-10-271-2/+3
|\
| * Fix compiler warning (git_off_t cast to size_t).Albert Meltzer2014-05-191-2/+3
| | | | | | | | | | | | Use size_t for page size, instead of long. Check result of sysconf. Use size_t for page offset so no cast to size_t (second arg to p_mmap). Use mod instead div/mult pair, so no cast to size_t is necessary.
* | Can read large file larger than 2GB on WindowsLinquize2014-08-101-4/+3
|/
* indexer: use mmap for writingCarlos Martín Nieto2014-05-171-0/+7
| | | | | | Some OSs cannot keep their ideas about file content straight when mixing standard IO with file mapping. As we use mmap for reading from the packfile, let's make writing to the pack file use mmap.
* Temporary fix for Travis CI buildsVicent Marti2014-05-021-1/+1
| | | | | See https://github.com/libgit2/libgit2/pull/2321#issuecomment-42039673 We may rollback once we found something more reliable
* Check for EWOULDBLOCK as well as EAGAIN on write.brian m. carlson2014-02-161-1/+1
| | | | | | | | | | | | | On some systems, notably HP PA-RISC systems running Linux or HP-UX, EWOULDBLOCK and EAGAIN are not the same value. POSIX (and these OSes) allow EWOULDBLOCK to occur on write(2) (and send(2), etc.), so check explicitly for this case as well as EAGAIN by defining and using a macro GIT_ISBLOCKED that considers both. The macro is necessary because MSYS does not provide EWOULDBLOCK and compilation fails if an attempt is made to use it unconditionally. On most systems, where the two values are the same, the compiler will simply optimize this check out and it will have no effect.
* Test cancel from indexer progress callbackRussell Belfer2013-12-111-0/+36
| | | | | | | | | | | | | | | This adds tests that try canceling an indexer operation from within the progress callback. After writing the tests, I wanted to run this under valgrind and had a number of errors in that situation because mmap wasn't working. I added a CMake option to force emulation of mmap and consolidated the Amiga-specific code into that new place (so we don't actually need separate Amiga code now, just have to turn on -DNO_MMAP). Additionally, I made the indexer code propagate error codes more reliably than it used to.
* Add O_CLOEXEC to open callsRussell Belfer2013-06-221-2/+2
|
* Fix memory leak in p_getaddrinfo on AmigaRussell Belfer2013-02-151-26/+23
| | | | | | | If gethostbyname() fails on platforms with NO_ADDRINFO, the code leaks the struct addrinfo that was allocated. This fixes that (and a number of code formatting issues in that area of code in src/posix.c).
* update copyrightsEdward Thomson2013-01-081-1/+1
|
* Move inet_pton to posix platform-compatibility layerEduardo Bart2012-11-071-0/+2
|
* amigaos: CleanupVicent Marti2012-06-221-1/+92
|
* Clean up warnings and testsRussell Belfer2012-05-081-1/+1
|
* compat: make p_open able to accept optional mode when passing the O_CREAT flagnulltoken2012-05-071-2/+13
| | | | This has the nice side effect of making test_attr_repo__staging_properly_normalizes_line_endings_according_to_gitattributes_directives() test pass again on Windows. This test started to fail after commit 674a198 was applied.
* Fix warnings on 64-bit windows buildsRussell Belfer2012-04-171-2/+14
| | | | | This fixes all the warnings on win64 except those in deps, which come from the regex code.
* Continue error conversionRussell Belfer2012-03-141-2/+2
| | | | | | | This converts blob.c, fileops.c, and all of the win32 files. Also, various minor cleanups throughout the code. Plus, in testing the win32 build, I cleaned up a bunch (although not all) of the warnings with the 64-bit build.
* error-handling: On-disk config file backendVicent Martí2012-03-091-10/+8
| | | | | | | | | | | | | | | Includes: - Proper error reporting when encountering syntax errors in a config file (file, line number, column). - Rewritten `config_write`, now with 99% less goto-spaghetti - Error state in `git_filebuf`: filebuf write functions no longer need to be checked for error returns. If any of the writes performed on a buffer fail, the last call to `git_filebuf_commit` or `git_filebuf_hash` will fail accordingly and set the appropiate error message. Baller!
* Update Copyright headerschu2012-02-131-1/+1
| | | | Signed-off-by: schu <schu-github@schulog.org>
* Use git_buf for path storage instead of stack-based buffersRussell Belfer2011-12-071-1/+2
| | | | | | | | | | | | | | | | | | | | This converts virtually all of the places that allocate GIT_PATH_MAX buffers on the stack for manipulating paths to use git_buf objects instead. The patch is pretty careful not to touch the public API for libgit2, so there are a few places that still use GIT_PATH_MAX. This extends and changes some details of the git_buf implementation to add a couple of extra functions and to make error handling easier. This includes serious alterations to all the path.c functions, and several of the fileops.c ones, too. Also, there are a number of new functions that parallel existing ones except that use a git_buf instead of a stack-based buffer (such as git_config_find_global_r that exists alongsize git_config_find_global). This also modifies the win32 version of p_realpath to allocate whatever buffer size is needed to accommodate the realpath instead of hardcoding a GIT_PATH_MAX limit, but that change needs to be tested still.
* Implement p_renameCarlos Martín Nieto2011-11-071-0/+14
| | | | | | Move the callers of git_futils_mv_atomic to use p_rename. Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
* fileops/posix: replace usage of "int mode" with "mode_t mode"Brodie Rao2011-10-141-1/+1
| | | | | Note: Functions exported from fileops take const mode_t, while the underlying POSIX wrappers take mode_t.
* Revert "Rewrite getenv to use Win32 version on Windows"Vicent Marti2011-09-271-9/+0
| | | | This reverts commit e1b86444676b70154bf8ab450d429bdef57a8276.
* Rewrite getenv to use Win32 version on WindowsPaul Betts2011-09-211-0/+9
|
* Rewrite p_* functions to use Unicode and marshal to UTF8 internallyPaul Betts2011-09-191-21/+21
|
* Cleanup legal dataVicent Marti2011-09-191-0/+6
| | | | | | | | | | 1. The license header is technically not valid if it doesn't have a copyright signature. 2. The COPYING file has been updated with the different licenses used in the project. 3. The full GPLv2 header in each file annoys me.
* posix: declare 'buf' argument of p_write() as constKirill A. Shutemov2011-07-251-2/+2
| | | | Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
* fileops: CleanupVicent Marti2011-07-051-0/+74
Cleaned up the structure of the whole OS-abstraction layer. fileops.c now contains a set of utility methods for file management used by the library. These are abstractions on top of the original POSIX calls. There's a new file called `posix.c` that contains emulations/reimplementations of all the POSIX calls the library uses. These are prefixed with `p_`. There's a specific posix file for each platform (win32 and unix). All the path-related methods have been moved from `utils.c` to `path.c` and have their own prefix.