On 29-Apr-20 12:50 AM, Dmitry Kozlyuk wrote:
EAL common code uses file locking and truncation. Introduce
OS-independent wrappers in order to support both Linux/FreeBSD
and Windows:

* eal_file_lock: lock or unlock an open file.
* eal_file_truncate: enforce a given size for an open file.

Wrappers follow POSIX semantics, but interface is not POSIX,
so that it can be made more clean, e.g. by not mixing locking
operation and behaviour on conflict.

Implementation for Linux and FreeBSD is placed in "unix" subdirectory,
which is intended for common code between the two. Files should be named
after the ones from which the code is factored in OS subdirectory.

Signed-off-by: Dmitry Kozlyuk <dmitry.kozl...@gmail.com>
---

<snip>

#include <rte_common.h>
  #include <rte_log.h>
@@ -85,7 +85,7 @@ resize_and_map(int fd, void *addr, size_t len)
        char path[PATH_MAX];
        void *map_addr;
- if (ftruncate(fd, len)) {
+       if (eal_file_truncate(fd, len)) {
                RTE_LOG(ERR, EAL, "Cannot truncate %s\n", path);
                /* pass errno up the chain */
                rte_errno = errno;

eal_file_truncate sets rte_errno, so no need to pass it up the chain any more.

Otherwise,

Acked-by: Anatoly Burakov <anatoly.bura...@intel.com>

--
Thanks,
Anatoly

Reply via email to