Source: pseudo
Version: 1.9.0+git20230301+ec6151a2b057-1
Followup-For: Bug #1084913
X-Debbugs-Cc: wuruil...@loongson.cn

Dear Maintainer,

Sorry, I just realized that the attachment didn't come with the email. Resend 
the attachment.

wuruilong
Description: <short summary of the patch>
 TODO: Put a short summary on the line above and replace this paragraph
 with a longer explanation of this change. Complete the meta-information
 with other relevant fields (see below for details). To make it easier, the
 information below has been extracted from the changelog. Adjust it or drop
 it.
 .
 pseudo (1.9.0+git20230301+ec6151a2b057-1) unstable; urgency=medium
 .
   * New upstream snapshot.
   * Add a build dependency on acl for tests.
Author: Andrej Shadura <andre...@debian.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout https://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: (upstream|backport|vendor|other), (<patch-url>|commit:<commit-id>)
Bug: <upstream-bugtracker-url>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: (no|not-needed|<patch-forwarded-url>)
Applied-Upstream: <version>, (<commit-url>|commit:<commid-id>)
Reviewed-By: <name and email of someone who approved/reviewed the patch>
Last-Update: 2024-10-25

--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/fopen64.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/fopen64.c
@@ -8,11 +8,13 @@
  * wrap_fopen64(const char *path, const char *mode) {
  *     FILE * rc = 0;
  */
-       struct stat64 buf;
-       int save_errno;
-
+        struct stat64 buf;
+        int save_errno;
+#ifdef __loongarch64
+        int existed = (real_stat64(path, &buf) != -1);
+#else
        int existed = (real___xstat64(_STAT_VER, path, &buf) != -1);
-
+#endif
        rc = real_fopen64(path, mode);
        save_errno = errno;
 
@@ -20,7 +22,11 @@
                int fd = fileno(rc);
 
                pseudo_debug(PDBGF_FILE, "fopen64 '%s': fd %d <FILE %p>\n", 
path, fd, (void *) rc);
+#ifdef __loongarch64
+               if (real_fstat64( fd, &buf) != -1) {
+#else
                if (real___fxstat64(_STAT_VER, fd, &buf) != -1) {
+#endif
                        if (!existed) {
                                real_fchmod(fd, PSEUDO_FS_MODE(0666 & 
~pseudo_umask, 0));
                                pseudo_client_op(OP_CREAT, 0, -1, -1, path, 
&buf);
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/freopen64.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/freopen64.c
@@ -10,7 +10,11 @@
  */
        struct stat64 buf;
        int save_errno;
+#ifdef __loongarch64
+       int existed = (real_stat64(path, &buf) != -1);
+#else
        int existed = (real___xstat64(_STAT_VER, path, &buf) != -1);
+#endif
 
        rc = real_freopen64(path, mode, stream);
        save_errno = errno;
@@ -19,7 +23,11 @@
                int fd = fileno(rc);
 
                pseudo_debug(PDBGF_FILE, "freopen64 '%s': fd %d\n", path, fd);
+#ifdef __loongarch64
+               if (real_fstat64(fd, &buf) != -1) {
+#else
                if (real___fxstat64(_STAT_VER, fd, &buf) != -1) {
+#endif
                        if (!existed) {
                                real_fchmod(fd, PSEUDO_FS_MODE(0666 & 
~pseudo_umask, 0));
                                pseudo_client_op(OP_CREAT, 0, -1, -1, path, 
&buf);
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/fstat.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/fstat.c
@@ -7,8 +7,17 @@
  * int fstat(int fd, struct stat *buf)
  *     int rc = -1;
  */
-
+#ifdef __loongarch64
+       struct stat64 buf64;
+        /* populate buffer with complete data */
+       real_fstat(fd, buf);
+        /* obtain fake data */
+       rc = wrap_fstat64(fd, &buf64);
+        /* overwrite */
+       pseudo_stat32_from64(buf, &buf64);
+#else
        rc = wrap___fxstat(_STAT_VER, fd, buf);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/fstat64.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/fstat64.c
@@ -7,8 +7,24 @@
  * int fstat64(int fd, struct stat *buf)
  *     int rc = -1;
  */
+#ifdef __loongarch64
+        pseudo_msg_t *msg;
+        int save_errno;
 
+        rc = real_fstat64(fd, buf);
+        save_errno = errno;
+        if (rc == -1) {
+                return rc;
+        }
+        msg = pseudo_client_op(OP_FSTAT, 0, fd, -1, 0, buf);
+        if (msg && msg->result == RESULT_SUCCEED) {
+                pseudo_stat_msg(buf, msg);
+        }
+
+        errno = save_errno;
+#else
        rc = wrap___fxstat64(_STAT_VER, fd, buf);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/fstatat.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/fstatat.c
@@ -7,8 +7,14 @@
  * int fstatat(int dirfd, const char *path, struct stat *buf, int flags)
  *     int rc = -1;
  */
-
+#ifdef __loongarch64
+       struct stat64 buf64;
+       real_fstatat(dirfd,path,buf,flags);
+       rc = wrap_fstatat64(dirfd, path, &buf64, flags);
+       pseudo_stat32_from64(buf, &buf64);
+#else
        rc = wrap___fxstatat(_STAT_VER, dirfd, path, buf, flags);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/fstatat64.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/fstatat64.c
@@ -8,7 +8,50 @@
  *     int rc = -1;
  */
 
+#ifdef __loongarch64
+        pseudo_msg_t *msg;
+        int save_errno;
+
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+        if (dirfd != AT_FDCWD) {
+                errno = ENOSYS;
+                return -1;
+        }
+#endif
+        if (flags & AT_SYMLINK_NOFOLLOW) {
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+                rc = real_lstat64(path, buf);
+#else
+                rc = real_fstatat64(dirfd, path, buf, flags);
+#endif
+                if (rc == -1) {
+                        return rc;
+                }
+        } else {
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+                rc = real_stat64( path, buf);
+#else
+                rc = real_fstatat64(dirfd, path, buf, flags);
+#endif
+                if (rc == -1) {
+                        return rc;
+                }
+        }
+        save_errno = errno;
+
+          /* query database
+         * note that symlink canonicalizing is now automatic, so we
+         * don't need to check for a symlink on this end
+         */
+        msg = pseudo_client_op(OP_STAT, 0, -1, dirfd, path, buf);
+        if (msg && msg->result == RESULT_SUCCEED) {
+                pseudo_stat_msg(buf, msg);
+        }
+
+        errno = save_errno;
+#else
        rc = wrap___fxstatat64(_STAT_VER, dirfd, path, buf, flags);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/lstat.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/lstat.c
@@ -7,8 +7,11 @@
  * int lstat(const char *path, struct stat *buf)
  *     int rc = -1;
  */
-
+#ifdef __loongarch64
+       rc = wrap_fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW);
+#else
        rc = wrap___fxstatat(_STAT_VER, AT_FDCWD, path, buf, 
AT_SYMLINK_NOFOLLOW);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/lstat64.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/lstat64.c
@@ -7,8 +7,11 @@
  * int lstat64(const char *path, struct stat *buf)
  *     int rc = -1;
  */
-
+#ifdef __loongarch64
+       rc = wrap_fstatat64( AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW);
+#else
        rc = wrap___fxstatat64(_STAT_VER, AT_FDCWD, path, buf, 
AT_SYMLINK_NOFOLLOW);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/mknod.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/mknod.c
@@ -8,7 +8,11 @@
  *     int rc = -1;
  */
 
+#ifdef __loongarch64
+       rc = wrap_mknodat(AT_FDCWD, path, mode, dev);
+#else
        rc = wrap___xmknod(_MKNOD_VER, path, mode, &dev);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/mknodat.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/mknodat.c
@@ -7,8 +7,80 @@
  * int mknodat(int dirfd, const char *path, mode_t mode, dev_t dev)
  *     int rc = -1;
  */
+#ifdef __loongarch64
+        pseudo_msg_t *msg;
+        struct stat64 buf;
 
+        /* mask out mode bits appropriately */
+        mode = mode & ~pseudo_umask;
+        /* if you don't specify a type, assume regular file */
+        if (!(mode & S_IFMT)) {
+                mode |= S_IFREG;
+        }
+        pseudo_debug(PDBGF_FILE, "mknodat creating '%s', mode 0%o\n",
+                path ? path : "<no name>", (int) mode);
+
+        /* we don't use underlying call, so _ver is irrelevant to us */
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+        if (dirfd != AT_FDCWD) {
+                errno = ENOSYS;
+                return -1;
+        }
+        rc = real_stat64( path, &buf);
+#else
+        rc = real_fstatat64( dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
+#endif
+        if (rc != -1) {
+                /* if we can stat the file, you can't mknod it */
+                errno = EEXIST;
+                return -1;
+        }
+        if (!dev) {
+                errno = EINVAL;
+                return -1;
+        }
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+        rc = real_open(path, O_CREAT | O_WRONLY | O_EXCL,
+                PSEUDO_FS_MODE(mode, 0));
+#else
+        rc = real_openat(dirfd, path, O_CREAT | O_WRONLY | O_EXCL,
+                PSEUDO_FS_MODE(mode, 0));
+#endif
+        if (rc == -1) {
+                return -1;
+        }
+        real_fchmod(rc, PSEUDO_FS_MODE(mode, 0));
+        real_fstat64( rc, &buf);
+        /* mknod does not really open the file.  We don't have
+         * to use wrap_close because we've never exposed this file
+         * descriptor to the client code.
+         */
+        real_close(rc);
+
+        /* mask in the mode type bits again */
+        buf.st_mode = (PSEUDO_DB_MODE(buf.st_mode, mode) & 07777) |
+                        (mode & ~07777);
+        buf.st_rdev = dev;
+        msg = pseudo_client_op(OP_MKNOD, 0, -1, dirfd, path, &buf);
+        if (msg && msg->result != RESULT_SUCCEED) {
+                errno = EPERM;
+                rc = -1;
+   } else {
+                /* just pretend we worked */
+                rc = 0;
+        }
+        if (rc == -1) {
+                int save_errno = errno;
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+                real_unlink(path);
+#else
+                real_unlinkat(dirfd, path, AT_SYMLINK_NOFOLLOW);
+#endif
+                errno = save_errno;
+        }
+#else
        rc = wrap___xmknodat(_MKNOD_VER, dirfd, path, mode, &dev);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/mkostemp64.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/mkostemp64.c
@@ -35,7 +35,11 @@
        if (rc != -1) {
                save_errno = errno;
 
+#ifdef __loongarch64
+               if (real_fstat64(rc, &buf) != -1) {
+#else
                if (real___fxstat64(_STAT_VER, rc, &buf) != -1) {
+#endif
                        real_fchmod(rc, PSEUDO_FS_MODE(0600, 0));
                        pseudo_client_op(OP_CREAT, 0, -1, -1, tmp_template, 
&buf);
                        pseudo_client_op(OP_OPEN, PSA_READ | PSA_WRITE, rc, -1, 
tmp_template, &buf);
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/openat.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/openat.c
@@ -56,13 +56,25 @@
                save_errno = errno;
 #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
                if (flags & O_NOFOLLOW) {
+#ifdef __loongarch64
+                       rc = real_lstat64(path,&buf);
+#else
                        rc = real___lxstat64(_STAT_VER, path, &buf);
+#endif
                } else {
+#ifdef __loongarch64
+                       rc = real_stat64(path,&buf);
+#else
                        rc = real___xstat64(_STAT_VER, path, &buf);
+#endif
                }
 #else
+#ifdef __loongarch64
+               rc = real_fstatat64(dirfd, path, &buf, (flags & O_NOFOLLOW) ? 
AT_SYMLINK_NOFOLLOW : 0);
+#else
                rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & 
O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
 #endif
+#endif
                existed = (rc != -1);
                if (!existed)
                        pseudo_debug(PDBGF_FILE, "openat_creat: %s -> 0%o\n", 
path, mode);
@@ -77,13 +89,25 @@
                save_errno = errno;
 #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
                if (flags & O_NOFOLLOW) {
+#ifdef __loongarch64
+                       rc = real_lstat64(path, &buf);
+#else
                        rc = real___lxstat64(_STAT_VER, path, &buf);
+#endif
                } else {
+#ifdef __loongarch64
+                       rc = real_stat64(path, &buf);
+#else
                        rc = real___xstat64(_STAT_VER, path, &buf);
+#endif
                }
 #else
+#ifdef __loongarch64
+               rc = real_fstatat64(dirfd, path, &buf, (flags & O_NOFOLLOW) ? 
AT_SYMLINK_NOFOLLOW : 0);
+#else
                rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, (flags & 
O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
 #endif
+#endif
                if (rc != -1 && S_ISFIFO(buf.st_mode)) {
                        overly_magic_nonblocking = 1;
                }
@@ -135,13 +159,25 @@
 #endif
 #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
                if (flags & O_NOFOLLOW) {
+#ifdef __loongarch64
+                       stat_rc = real_lstat64( path, &buf);
+#else
                        stat_rc = real___lxstat64(_STAT_VER, path, &buf);
+#endif
                } else {
+#ifdef __loongarch64
+                       stat_rc = real_stat64(path, &buf);
+#else
                        stat_rc = real___xstat64(_STAT_VER, path, &buf);
+#endif
                }
 #else
+#ifdef __loongarch64
+               stat_rc = real_fstatat64(dirfd, path, &buf, (flags & 
O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
+#else
                stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, 
(flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0);
 #endif
+#endif
 
                pseudo_debug(PDBGF_FILE, "openat(path %s), flags %o, stat rc 
%d, stat mode %o\n",
                        path, flags, stat_rc, buf.st_mode);
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/stat.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/stat.c
@@ -7,8 +7,11 @@
  * int stat(const char *path, struct stat *buf)
  *     int rc = -1;
  */
-
+#ifdef __loongarch64
+       rc = wrap_fstatat(AT_FDCWD, path, buf, 0);
+#else
        rc = wrap___fxstatat(_STAT_VER, AT_FDCWD, path, buf, 0);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/guts/stat64.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/guts/stat64.c
@@ -7,8 +7,11 @@
  * int stat64(const char *path, struct stat *buf)
  *     int rc = -1;
  */
-
+#ifdef __loongarch64
+       rc = wrap_fstatat64(AT_FDCWD, path, buf, 0);
+#else
        rc = wrap___fxstatat64(_STAT_VER, AT_FDCWD, path, buf, 0);
+#endif
 
 /*     return rc;
  * }
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/ports/linux/pseudo_wrappers.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/ports/linux/pseudo_wrappers.c
@@ -8,43 +8,75 @@
  */
 int
 pseudo_stat(const char *path, struct stat *buf) {
+#ifdef __loongarch64
+       return real_stat( path, buf);
+#else
        return real___xstat(_STAT_VER, path, buf);
+#endif
 }
 
 int
 pseudo_lstat(const char *path, struct stat *buf) {
+#ifdef __loongarch64
+       return real_lstat(path,buf);
+#else
        return real___lxstat(_STAT_VER, path, buf);
+#endif
 }
 
 int
 pseudo_fstat(int fd, struct stat *buf) {
+#ifdef __loongarch64
+       return real_fstat(fd,buf);
+#else
        return real___fxstat(_STAT_VER, fd, buf);
+#endif
 }
 
 int
 pseudo_stat64(const char *path, struct stat64 *buf) {
+#ifdef __loongarch64
+       return real_stat64(path,buf);
+#else
        return real___xstat64(_STAT_VER, path, buf);
+#endif
 }
 
 int
 pseudo_lstat64(const char *path, struct stat64 *buf) {
+#ifdef __loongarch64
+       return real_lstat64(path,buf);
+#else
        return real___lxstat64(_STAT_VER, path, buf);
+#endif
 }
 
 int
 pseudo_fstat64(int fd, struct stat64 *buf) {
+#ifdef __loongarch64
+       return  real_fstat64(fd,buf);
+#else
        return real___fxstat64(_STAT_VER, fd, buf);
+#endif
 }
 
 /* similar thing happens with mknod */
 int
 pseudo_mknod(const char *path, mode_t mode, dev_t dev) {
+#ifdef __loongarch64
+       return real_mknod(path,mode,dev);
+#else
        return real___xmknod(_MKNOD_VER, path, mode, &dev);
+#endif
 }
 
 int
 pseudo_mknodat(int dirfd, const char *path, mode_t mode, dev_t dev) {
+#ifdef __loongarch64
+       return real_mknodat(dirfd,path,mode,dev);
+#else
        return real___xmknodat(_MKNOD_VER, dirfd, path, mode, &dev);
+#endif
 }
 
 int pseudo_capset(cap_user_header_t hdrp, const cap_user_data_t datap) {
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/pseudo_client.h
+++ pseudo-1.9.0+git20230301+ec6151a2b057/pseudo_client.h
@@ -14,13 +14,21 @@ extern void pseudo_client_linked_paths(c
 #define base_lstat real_lstat64
 #define base_fstat real_fstat64
 #define base_stat real_stat64
+#ifdef __loongarch64
+#define base_fstatat(dirfd, path, buf, flags) real_fstatat64( dirfd, path, 
buf, flags)
+#else
 #define base_fstatat(dirfd, path, buf, flags) real___fxstatat64(_STAT_VER, 
dirfd, path, buf, flags)
+#endif
 #else
 #define base_lstat real_lstat
 #define base_fstat real_fstat
 #define base_stat real_stat
+#ifdef __loongarch64
+#define base_fstatat(dirfd, path, buf, flags) real_fstatat( dirfd, path, buf, 
flags
+#else
 #define base_fstatat(dirfd, path, buf, flags) real___fxstatat(_STAT_VER, 
dirfd, path, buf, flags)
 #endif
+#endif
 extern void pseudo_antimagic(void);
 extern void pseudo_magic(void);
 extern void pseudo_client_touchuid(void);
--- pseudo-1.9.0+git20230301+ec6151a2b057.orig/templates/wrapfuncs.c
+++ pseudo-1.9.0+git20230301+ec6151a2b057/templates/wrapfuncs.c
@@ -13,7 +13,9 @@
  * script if you want to modify this. */
 @body
 
+#ifndef __loongarch64
 static ${type} (*real_${name})(${decl_args}) = ${real_init};
+#endif
 
 ${maybe_skip}
 

Reply via email to