Skip to content

Commit

Permalink
Merge branch 'jb45802' into 'master'
Browse files Browse the repository at this point in the history
[sb2] Add support for _FILE_OFFSET_BITS=64 / largefile functions. JB#45802

See merge request mer-core/scratchbox2!24
  • Loading branch information
Matti Kosola committed Jan 31, 2020
2 parents 75dc678 + a9cf174 commit a28aa6d
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 66 deletions.
4 changes: 2 additions & 2 deletions scratchbox2/execs/sb_exec.c
Expand Up @@ -375,7 +375,7 @@ static enum binary_type inspect_binary(const char *filename,
static const char *target_cpu = NULL;
enum binary_type retval;
int fd, j;
struct stat status;
struct stat64 status;
char *region;
unsigned int ei_data;
uint16_t e_machine;
Expand Down Expand Up @@ -455,7 +455,7 @@ static enum binary_type inspect_binary(const char *filename,

retval = BIN_UNKNOWN;

if (sb2_fstat(fd, &status) < 0) {
if (sb2_fstat64(fd, &status) < 0) {
SB_LOG(SB_LOGLEVEL_DEBUG,
"%s: fstat failed => out", __func__);
goto _out_close;
Expand Down
6 changes: 5 additions & 1 deletion scratchbox2/include/sb2_stat.h
Expand Up @@ -13,9 +13,13 @@
#include <unistd.h>

extern int real_lstat(const char *path, struct stat *statbuf);
extern int real_lstat64(const char *path, struct stat64 *statbuf);
extern int real_stat(const char *path, struct stat *statbuf);
extern int real_stat64(const char *path, struct stat64 *statbuf);
extern int real_fstat(int fd, struct stat *statbuf);
extern int real_fstat64(int fd, struct stat64 *statbuf);
extern int real_fstatat(int dirfd, const char *path, struct stat *statbuf, int flags);
extern int real_fstatat64(int dirfd, const char *path, struct stat64 *statbuf, int flags);

extern int i_virtualize_struct_stat(const char *realfnname,
struct stat *buf, struct stat64 *buf64);
Expand All @@ -30,6 +34,6 @@ extern int sb2_stat64_file(const char *path, struct stat64 *buf, int *result_err
int ver,
int (*stat64fn_ptr)(const char *filename, struct stat64 *buf));

extern int sb2_fstat(int fd, struct stat *statbuf);
extern int sb2_fstat64(int fd, struct stat64 *statbuf);

#endif
4 changes: 2 additions & 2 deletions scratchbox2/pathmapping/pathresolution.c
Expand Up @@ -641,8 +641,8 @@ static ruletree_object_offset_t sb_path_resolution(
if (ctx->pmc_must_be_directory &&
virtual_path_work_ptr->pe_next == NULL) {
/* must be a directory, check it */
struct stat statbuf;
if (real_stat(prefix_mapping_result_host_path, &statbuf) < 0) {
struct stat64 statbuf;
if (real_stat64(prefix_mapping_result_host_path, &statbuf) < 0) {
resolved_virtual_path_res->mres_errno = errno;
SB_LOG(SB_LOGLEVEL_NOISE,
"Path resolution failed, unable to stat directory, errno=%d",
Expand Down
4 changes: 2 additions & 2 deletions scratchbox2/preload/chrootgate.c
Expand Up @@ -35,7 +35,7 @@ int chroot_gate(int *result_errno_ptr,
{
char *new_chroot_path = NULL;
char *cp = NULL;
struct stat statbuf;
struct stat64 statbuf;
mapping_results_t mapped_chroot_path;

(void)real_chroot_ptr; /* won't call the real function ever */
Expand Down Expand Up @@ -111,7 +111,7 @@ int chroot_gate(int *result_errno_ptr,
/* check if the target exists. */
SB_LOG(SB_LOGLEVEL_DEBUG, "chroot: testing '%s'",
mapped_chroot_path.mres_result_path);
if (real_stat(mapped_chroot_path.mres_result_path, &statbuf) < 0) {
if (real_stat64(mapped_chroot_path.mres_result_path, &statbuf) < 0) {
SB_LOG(SB_LOGLEVEL_DEBUG, "chroot: failed to stat the destination dir (%s)",
mapped_chroot_path.mres_result_path);
*result_errno_ptr = ENOENT;
Expand Down
13 changes: 11 additions & 2 deletions scratchbox2/preload/interface.master
Expand Up @@ -267,14 +267,16 @@ WRAP: int fcntl64(int fd, int cmd, ...) : \
GATE: int __fxstat(int ver, int fd, struct stat *buf) : class(STAT) \
create_nomap_nolog_version

GATE: int __fxstat64(int ver, int fd, struct stat64 *buf) : class(STAT)
GATE: int __fxstat64(int ver, int fd, struct stat64 *buf) : class(STAT) \
create_nomap_nolog_version

GATE: int __lxstat(int ver, const char *filename, struct stat *buf) : \
create_nomap_nolog_version \
dont_resolve_final_symlink map(filename) class(STAT)

#ifdef HAVE___LXSTAT64
GATE: int __lxstat64(int ver, const char *filename, struct stat64 *buf) : \
create_nomap_nolog_version \
dont_resolve_final_symlink map(filename) class(STAT)
#endif

Expand All @@ -297,7 +299,9 @@ GATE: int __xstat(int ver, const char *filename, struct stat *buf) : \
map(filename) class(STAT)

#ifdef HAVE___XSTAT64
GATE: int __xstat64(int ver, const char *filename, struct stat64 *buf) : map(filename) class(STAT)
GATE: int __xstat64(int ver, const char *filename, struct stat64 *buf) : \
create_nomap_nolog_version \
map(filename) class(STAT)
#endif

#ifdef AT_SYMLINK_NOFOLLOW
Expand All @@ -306,6 +310,7 @@ GATE: int __fxstatat(int ver, int dirfd, const char *pathname, struct stat *buf,
dont_resolve_final_symlink_if(flags&AT_SYMLINK_NOFOLLOW) \
map_at(dirfd,pathname) class(STAT)
GATE: int __fxstatat64(int ver, int dirfd, const char *pathname, struct stat64 *buf, int flags) : \
create_nomap_nolog_version \
dont_resolve_final_symlink_if(flags&AT_SYMLINK_NOFOLLOW) \
map_at(dirfd,pathname) class(STAT)
#endif
Expand Down Expand Up @@ -417,6 +422,9 @@ GATE: FILE *freopen64(const char *path, const char *mode, FILE *stream) : \
GATE: int fstat(int fd, struct stat *buf) : class(STAT) \
create_nomap_nolog_version

GATE: int fstat64(int fd, struct stat64 *buf) : class(STAT) \
create_nomap_nolog_version

#ifdef AT_SYMLINK_NOFOLLOW
WRAP: int fstatat(int dirfd, const char *pathname, struct stat *buf, int flags) : \
dont_resolve_final_symlink_if(flags&AT_SYMLINK_NOFOLLOW) \
Expand Down Expand Up @@ -508,6 +516,7 @@ WRAP: int lstat(const char *file_name, struct stat *buf) : \

#ifdef HAVE_LSTAT64
WRAP: int lstat64(const char *file_name, struct stat64 *buf) : \
create_nomap_nolog_version \
dont_resolve_final_symlink map(file_name) class(STAT)
#endif

Expand Down

0 comments on commit a28aa6d

Please sign in to comment.