Move __*xstat* and __xmknod functions to new subport 'old__x'
A message that is not in the archive (sent off-list or not yet received): [email protected]
Review
Quoted 2 lines · On Tue, 30 May 2023 19:54:41 -0700 Mark Hatle <[email protected]> wrote:
(quoted diff) +1
-1- int existed = (real___xstat64(_STAT_VER, path, &buf) != -1); + int existed = (base_stat64(path, &buf) != -1);
Honestly, with the benefit of hindsight, I actually can't even think why I ever thought I should be using those directly instead of through the base_foo wrappers. Probably for a reason.
... Just in case, definitely don't merge this before testing it in case there's some insane reason for which the base_* wrappers didn't work here.
Quoted 409 lines
(quoted diff) +1
-1rc = real_fopen64(path, mode); save_errno = errno;@@ -20,7 +20,7 @@ int fd = fileno(rc); pseudo_debug(PDBGF_FILE, "fopen64 '%s': fd %d <FILE %p>\n", path, fd, (void *) rc); - if (real___fxstat64(_STAT_VER, fd, &buf) != -1) { + if (base_fstat64(fd, &buf) != -1) { if (!existed) { real_fchmod(fd, PSEUDO_FS_MODE(0666& ~pseudo_umask, 0));
pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf); diff --gita/ports/linux/guts/freopen64.cb/ports/linux/guts/freopen64.cindex 5fc9073..9bcc06a 100644ports/linux/guts/freopen64.c +2
-2@@ -10,7 +10,7 @@*/ struct stat64 buf;int save_errno; -int existed = (real___xstat64 (_STAT_VER, path, &buf) !=-1 ); +int existed = (base_stat64 (path, &buf) !=-1 ); rc =real_freopen64 (path, mode, stream); save_errno = errno;@@ -19,7 +19,7 @@int fd =fileno (rc);pseudo_debug (PDBGF_FILE ,"freopen64 '%s': fd %d\n" , path, fd); -if (real___fxstat64 (_STAT_VER, fd, &buf) !=-1 ) { +if (base_fstat64 (fd, &buf) !=-1 ) {if (!existed) { real_fchmod(fd, PSEUDO_FS_MODE(0666& ~pseudo_umask, 0));
pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf); diff --gita/ports/linux/guts/fstat.cb/ports/linux/guts/fstat.cindex b089b15..80933e2 100644ports/linux/guts/fstat.c +7
-1@@ -8,7 +8,13 @@* int rc = -1; */ - rc =wrap___fxstat (_STAT_VER, fd, buf); +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);/* return rc; * } ports/linux/guts/fstat64.c +13
-1@@ -8,8 +8,20 @@* int rc = -1; */ - rc =wrap___fxstat64 (_STAT_VER, fd, buf); +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;/* return rc; * } */ ports/linux/guts/fstatat.c +8
-1@@ -1,4 +1,5 @@/* +* Copyright (c) 2008-2010 Wind River Systems; see * Copyright (c) 2021 Linux Foundation; see * guts/COPYRIGHT for information. * @@ -8,7 +9,13 @@* int rc = -1; */ - rc =wrap___fxstatat (_STAT_VER, dirfd, path, buf, flags); +struct stat64 buf64; +/* populate buffer with complete data */ +real_fstatat (dirfd, path, buf, flags); +/* obtain fake data */ + rc =wrap_fstatat64 (dirfd, path, &buf64, flags); +/* overwrite */ +pseudo_stat32_from64 (buf, &buf64);/* return rc; * } (quoted diff) +0
-0
b/ports/linux/guts/fstatat64.cindex c981e14..13c1143 100644ports/linux/guts/fstatat64.c +41
-1@@ -1,4 +1,5 @@/* +* Copyright (c) 2008-2010 Wind River Systems; * Copyright (c) 2021 Linux Foundation; see * guts/COPYRIGHT for information. * @@ -8,7 +9,46 @@* int rc = -1; */ - rc =wrap___fxstatat64 (_STAT_VER, dirfd, path, buf, flags); +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;/* return rc; * } ports/linux/guts/lstat.c +1
-1@@ -8,7 +8,7 @@* int rc = -1; */ - rc =wrap___fxstatat (_STAT_VER,AT_FDCWD , path, buf, AT_SYMLINK_NOFOLLOW); + rc =wrap_fstatat (AT_FDCWD , path, buf,AT_SYMLINK_NOFOLLOW );/* return rc; * }
ports/linux/guts/lstat64.c +1
-1@@ -8,7 +8,7 @@* int rc = -1; */ - rc =wrap___fxstatat64 (_STAT_VER,AT_FDCWD , path, buf, AT_SYMLINK_NOFOLLOW); + rc =wrap_fstatat64 (AT_FDCWD , path, buf,AT_SYMLINK_NOFOLLOW );/* return rc; * }
ports/linux/guts/mknod.c +1
-1@@ -8,7 +8,7 @@* int rc = -1; */ - rc =wrap___xmknod (_MKNOD_VER, path, mode, &dev); + rc =wrap_mknodat (AT_FDCWD , path, mode, dev);/* return rc; * } ports/linux/guts/mknodat.c +70
-1@@ -1,4 +1,5 @@/* +* Copyright (c) 2008-2010 Wind River Systems; see * Copyright (c) 2016 Wind River Systems; see * guts/COPYRIGHT for information. * @@ -8,7 +9,75 @@* int rc = -1; */ - rc =wrap___xmknodat (_MKNOD_VER, dirfd, path, mode, &dev); +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); + +#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; + }/* return rc; * } (quoted diff) +0
-0
b/ports/linux/guts/mkostemp64.cindex 502211b..694070b 100644ports/linux/guts/mkostemp64.c +1
-1@@ -35,7 +35,7 @@if (rc !=-1 ) { save_errno = errno; -if (real___fxstat64 (_STAT_VER, rc, &buf) !=-1 ) { +if (base_fstat64 (rc, &buf) !=-1 ) {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); diff --gita/ports/linux/guts/openat.cb/ports/linux/guts/openat.cindex 656ac2b..d027154 100644ports/linux/guts/openat.c +3
-3@@ -56,12 +56,12 @@ save_errno = errno;#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS if (flags &O_NOFOLLOW ) { - rc =real___lxstat64 (_STAT_VER, path, &buf); + rc =base_lstat64 (path, &buf); }else { - rc =real___xstat64 (_STAT_VER, path, &buf); + rc =base_stat64 (path, &buf); }#else - rc =real___fxstatat64 (_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); + rc = base_fstatat64(dirfd, path, &buf, (flags &
O_NOFOLLOW) ?AT_SYMLINK_NOFOLLOW: 0); #endifports/linux/guts/openat.c +3
-3existed = (rc !=-1 );if (!existed)@@ -77,12 +77,12 @@ save_errno = errno;#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS if (flags &O_NOFOLLOW ) { - rc =real___lxstat64 (_STAT_VER, path, &buf); + rc =base_lstat64 (path, &buf); }else { - rc =real___xstat64 (_STAT_VER, path, &buf); + rc =base_stat64 (path, &buf); }#else - rc =real___fxstatat64 (_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); + rc = base_fstatat64(dirfd, path, &buf, (flags &
O_NOFOLLOW) ?AT_SYMLINK_NOFOLLOW: 0); #endifports/linux/guts/openat.c +3
-3if (rc !=-1 &&S_ISFIFO (buf.st_mode)) { overly_magic_nonblocking =1 ;@@ -135,12 +135,12 @@#endif #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS if (flags &O_NOFOLLOW ) { - stat_rc =real___lxstat64 (_STAT_VER, path, &buf); + stat_rc =base_lstat64 (path, &buf); }else { - stat_rc =real___xstat64 (_STAT_VER, path, &buf); + stat_rc =base_xstat64 (path, &buf); }#else - stat_rc =real___fxstatat64 (_STAT_VER, dirfd, path, &buf, (flags & O_NOFOLLOW) ? AT_SYMLINK_NOFOLLOW : 0); + stat_rc = base_fstatat64(dirfd, path, &buf, (flags &
O_NOFOLLOW) ?AT_SYMLINK_NOFOLLOW: 0); #endifpseudo_debug(PDBGF_FILE, "openat(path %s), flags %o,
stat rc %d, stat mode %o\n", diff --gita/ports/linux/guts/stat.cb/ports/linux/guts/stat.cindex f8c73f7..ccd00db 100644ports/linux/guts/stat.c +1
-1@@ -8,7 +8,7 @@* int rc = -1; */ - rc =wrap___fxstatat (_STAT_VER,AT_FDCWD , path, buf,0 ); + rc =wrap_fstatat (AT_FDCWD , path, buf,0 );/* return rc; * } ports/linux/guts/stat64.c +1
-1@@ -8,7 +8,7 @@* int rc = -1; */ - rc =wrap___fxstatat64 (_STAT_VER,AT_FDCWD , path, buf,0 ); + rc =wrap_fstatat64 (AT_FDCWD , path, buf,0 );/* return rc; * } ports/linux/old__x/README new file +13
-0@@ -0,0 +1,28 @@ +Older glibcs contain stat functions such as: + +__fxstat +__fxstatat +__lxstat +__xstat + +__fxstat64 +__fxstatat64 +__lxstat64 +__xstat64 + +The format of these functions use the _STAT_VER defintion. Newglibc no +longer define or utilize these functions, so neither can we.
ports/linux/old__x/README new file +2
-0+ +We only use this subport when the functions are present, this is
Quoted 1 line
checked +by with the existence of
_STAT_VER.
"by with the existence"? Looks like a typo.
Anyway, looks reasonable to me, thanks!
-s
Quoted 10 lines · Seebs
Review
Quoted 2 lines · On Tue, 30 May 2023 19:54:41 -0700 Mark Hatle <[email protected]> wrote:
(quoted diff) +1
-1- int existed = (real___xstat64(_STAT_VER, path, &buf) != -1); + int existed = (base_stat64(path, &buf) != -1);Honestly, with the benefit of hindsight, I actually can't even think why I ever thought I should be using those directly instead of through the
base_foowrappers. Probably for a reason.
Quoted 3 lines
... Just in case, definitely don't merge this before testing it in case there's some insane reason for which the base_* wrappers didn't work here.
Ya, it's going to require some soak time in the master-next and various builds I suspect.
...
Quoted 17 lines
Quoted 17 lines
ports/linux/old__x/README new file +11
-0@@ -0,0 +1,28 @@ +Older glibcs contain stat functions such as: + +__fxstat +__fxstatat +__lxstat +__xstat + +__fxstat64 +__fxstatat64 +__lxstat64 +__xstat64
Quoted 8 lines
Quoted 6 lines
ports/linux/old__x/README new file +2
-0+ +The format of these functions use the _STAT_VER defintion. Newglibc no +longer define or utilize these functions, so neither can we.
ports/linux/old__x/README new file +2
-0+ +We only use this subport when the functions are present, this ischecked +by with the existence of
_STAT_VER."by with the existence"? Looks like a typo.
Ya, I forgot to clean that up, how does this look as a replacement:
Older glibcs contain xstat functions such as:
__fxstat__fxstatat__lxstat__xstat
__fxstat64__fxstatat64__lxstat64__xstat64
These functions are defined when the _STAT_VER is also defined.
Similarly these xmknod functions are also only defined in older glibcs:
__xmknod__xmknodat
These functions are defind when the _MKNOD_VER is also defined.
This subport is automatically enabled with BOTH _STAT_VER and _MKNOD_VER are present. Alternatively if the user force enables subport, it should work as long as the symbols for these functions are still available.
Quoted 3 lines
Anyway, looks reasonable to me, thanks!
-s