Mercurial > unleashed > wips
changeset 20468:0e393b6786cf
libproc: remove rlimit64 and stat64 usage
author | Lauri Tirkkonen <lotheac@iki.fi> |
---|---|
date | Tue, 12 Mar 2019 00:28:57 +0200 |
parents | 2778d3b98beb |
children | 90e56e99d821 |
files | usr/src/cmd/nohup/nohup.c usr/src/cmd/plimit/plimit.c usr/src/lib/libproc/common/Pcontrol.c usr/src/lib/libproc/common/Pcontrol.h usr/src/lib/libproc/common/Pcore.c usr/src/lib/libproc/common/Pfdinfo.c usr/src/lib/libproc/common/Pgcore.c usr/src/lib/libproc/common/Pidle.c usr/src/lib/libproc/common/Pzone.c usr/src/lib/libproc/common/libproc.h usr/src/lib/libproc/common/mapfile-vers usr/src/lib/libproc/common/pr_getrlimit.c usr/src/lib/libproc/common/pr_stat.c usr/src/lib/libproc/common/proc_arg.c |
diffstat | 14 files changed, 70 insertions(+), 532 deletions(-) [+] |
line wrap: on
line diff
--- a/usr/src/cmd/nohup/nohup.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/cmd/nohup/nohup.c Tue Mar 12 00:28:57 2019 +0200 @@ -254,7 +254,7 @@ /* * See if this fd refers to the controlling tty. */ - if (pr_fstat64(g_proc, fd, &sbuf) == -1 || + if (pr_fstat(g_proc, fd, &sbuf) == -1 || sbuf.st_rdev != Ppsinfo(g_proc)->pr_ttydev) return (0);
--- a/usr/src/cmd/plimit/plimit.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/cmd/plimit/plimit.c Tue Mar 12 00:28:57 2019 +0200 @@ -55,7 +55,7 @@ static int mbytes = FALSE; static char set_current[RLIM_NLIMITS]; static char set_maximum[RLIM_NLIMITS]; -static struct rlimit64 rlimit[RLIM_NLIMITS]; +static struct rlimit rlimit[RLIM_NLIMITS]; static void intr(int); static int parse_limits(int, char *); @@ -235,10 +235,10 @@ * mm : ss minutes and seconds (for CPU time only) */ static int -limit_value(int which, char *arg, rlim64_t *limit) +limit_value(int which, char *arg, rlim_t *limit) { - rlim64_t value; - rlim64_t unit; + rlim_t value; + rlim_t unit; char *lastc; if (strcmp(arg, "unlimited") == 0) { @@ -249,7 +249,7 @@ if (which == RLIMIT_CPU && strchr(arg, ':') != NULL) { char *minutes = strtok_r(arg, " \t:", &lastc); char *seconds = strtok_r(NULL, " \t", &lastc); - rlim64_t sec; + rlim_t sec; if (seconds != NULL && strtok_r(NULL, " \t", &lastc) != NULL) return (1); @@ -319,7 +319,7 @@ char *lastc; char *soft = strtok_r(arg, " \t,", &lastc); char *hard = strtok_r(NULL, " \t", &lastc); - struct rlimit64 *rp = &rlimit[which]; + struct rlimit *rp = &rlimit[which]; if (hard != NULL && strtok_r(NULL, " \t", &lastc) != NULL) return (1); @@ -349,7 +349,7 @@ } static void -limit_adjust(struct rlimit64 *rp, int units) +limit_adjust(struct rlimit *rp, int units) { if (rp->rlim_cur != RLIM64_INFINITY) rp->rlim_cur /= units; @@ -358,7 +358,7 @@ } static char * -limit_values(struct rlimit64 *rp) +limit_values(struct rlimit *rp) { static char buffer[64]; char buf1[32]; @@ -388,7 +388,7 @@ static void show_limits(struct ps_prochandle *Pr) { - struct rlimit64 rlim; + struct rlimit rlim; int resource; char buf[32]; char *s; @@ -396,7 +396,7 @@ (void) printf(" resource\t\t current\t maximum\n"); for (resource = 0; resource < RLIM_NLIMITS; resource++) { - if (pr_getrlimit64(Pr, resource, &rlim) != 0) + if (pr_getrlimit(Pr, resource, &rlim) != 0) continue; switch (resource) { @@ -468,15 +468,15 @@ } static int -set_one_limit(struct ps_prochandle *Pr, int which, rlim64_t cur, rlim64_t max) +set_one_limit(struct ps_prochandle *Pr, int which, rlim_t cur, rlim_t max) { - struct rlimit64 rlim; + struct rlimit rlim; int be_su = 0; prpriv_t *old_prpriv = NULL, *new_prpriv = NULL; priv_set_t *eset, *pset; int ret = 0; - if (pr_getrlimit64(Pr, which, &rlim) != 0) { + if (pr_getrlimit(Pr, which, &rlim) != 0) { (void) fprintf(stderr, "%s: unable to get process limit for pid %d: %s\n", command, Pstatus(Pr)->pr_pid, strerror(errno)); @@ -547,7 +547,7 @@ } } - if (pr_setrlimit64(Pr, which, &rlim) != 0) { + if (pr_setrlimit(Pr, which, &rlim) != 0) { (void) fprintf(stderr, "%s: cannot set resource limit for pid %d: %s\n", command, Pstatus(Pr)->pr_pid, strerror(errno));
--- a/usr/src/lib/libproc/common/Pcontrol.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/Pcontrol.c Tue Mar 12 00:28:57 2019 +0200 @@ -256,10 +256,10 @@ static int stat_exec(const char *path, void *arg) { - struct stat64 *stp = arg; - struct stat64 st; - - return (stat64(path, &st) == 0 && S_ISREG(st.st_mode) && + struct stat *stp = arg; + struct stat st; + + return (stat(path, &st) == 0 && S_ISREG(st.st_mode) && stp->st_dev == st.st_dev && stp->st_ino == st.st_ino); } @@ -270,7 +270,7 @@ char exec_name[PATH_MAX]; char cwd[PATH_MAX]; char proc_cwd[64]; - struct stat64 st; + struct stat st; int ret; /* @@ -291,7 +291,7 @@ (void) snprintf(exec_name, sizeof (exec_name), "%s/%d/object/a.out", procfs_path, (int)P->pid); - if (stat64(exec_name, &st) != 0 || !S_ISREG(st.st_mode)) + if (stat(exec_name, &st) != 0 || !S_ISREG(st.st_mode)) return (NULL); /* @@ -2880,14 +2880,14 @@ { prheader_t *Lhp; char lpath[PATH_MAX]; - struct stat64 statb; + struct stat statb; int fd; size_t size; ssize_t rval; (void) snprintf(lpath, sizeof (lpath), "%s/%d/%s", procfs_path, (int)P->status.pr_pid, lname); - if ((fd = open(lpath, O_RDONLY)) < 0 || fstat64(fd, &statb) != 0) { + if ((fd = open(lpath, O_RDONLY)) < 0 || fstat(fd, &statb) != 0) { if (fd >= 0) (void) close(fd); return (NULL); @@ -3856,7 +3856,7 @@ * outside these two functions. */ int -Padd_mapping(struct ps_prochandle *P, off64_t off, file_info_t *fp, +Padd_mapping(struct ps_prochandle *P, off_t off, file_info_t *fp, prmap_t *pmap) { map_info_t *mp;
--- a/usr/src/lib/libproc/common/Pcontrol.h Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/Pcontrol.h Tue Mar 12 00:28:57 2019 +0200 @@ -128,7 +128,7 @@ typedef struct map_info { /* description of an address space mapping */ prmap_t map_pmap; /* /proc description of this mapping */ file_info_t *map_file; /* pointer into list of mapped files */ - off64_t map_offset; /* offset into core file (if core) */ + off_t map_offset; /* offset into core file (if core) */ int map_relocate; /* associated file_map needs to be relocated */ } map_info_t; @@ -156,7 +156,7 @@ plist_t core_lwp_head; /* head of list of lwp info */ lwp_info_t *core_lwp; /* current lwp information */ uint_t core_nlwp; /* number of lwp's in list */ - off64_t core_size; /* size of core file in bytes */ + off_t core_size; /* size of core file in bytes */ char *core_platform; /* platform string from core file */ struct utsname *core_uts; /* uname(2) data from core file */ prcred_t *core_cred; /* process credential from core file */ @@ -288,7 +288,7 @@ extern char *Pfindmap(struct ps_prochandle *, map_info_t *, char *, size_t); -extern int Padd_mapping(struct ps_prochandle *, off64_t, file_info_t *, +extern int Padd_mapping(struct ps_prochandle *, off_t, file_info_t *, prmap_t *); extern void Psort_mappings(struct ps_prochandle *);
--- a/usr/src/lib/libproc/common/Pcore.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/Pcore.c Tue Mar 12 00:28:57 2019 +0200 @@ -69,7 +69,7 @@ */ static ssize_t core_rw(struct ps_prochandle *P, void *buf, size_t n, uintptr_t addr, - ssize_t (*prw)(int, void *, size_t, off64_t)) + ssize_t (*prw)(int, void *, size_t, off_t)) { ssize_t resid = n; @@ -78,7 +78,7 @@ uintptr_t mapoff; ssize_t len; - off64_t off; + off_t off; int fd; if (mp == NULL) @@ -131,7 +131,7 @@ void *data) { return (core_rw(P, (void *)buf, n, addr, - (ssize_t (*)(int, void *, size_t, off64_t)) pwrite64)); + (ssize_t (*)(int, void *, size_t, off_t)) pwrite64)); } /*ARGSUSED*/ @@ -1136,7 +1136,7 @@ int err = 0; (void) pread64(P->asfd, &err, - sizeof (err), (off64_t)php->p_offset); + sizeof (err), (off_t)php->p_offset); Perror_printf(P, errfmt, addr, strerror(err)); dprintf(errfmt, addr, strerror(err)); @@ -1149,7 +1149,7 @@ (void) memset(&killinfo, 0, sizeof (killinfo)); (void) pread64(P->asfd, &killinfo, - sizeof (killinfo), (off64_t)php->p_offset); + sizeof (killinfo), (off_t)php->p_offset); /* * While there is (or at least should be) only one segment that has @@ -1275,7 +1275,7 @@ GElf_Shdr *symtab, GElf_Shdr *strtab) { size_t size; - off64_t off, base; + off_t off, base; map_info_t *mp; file_info_t *fp; Elf_Scn *scn; @@ -1727,7 +1727,7 @@ { (void) memset(efp, 0, sizeof (elf_file_t)); - if ((efp->e_fd = open64(path, O_RDONLY)) >= 0) { + if ((efp->e_fd = open(path, O_RDONLY)) >= 0) { if (core_elf_fdopen(efp, type, perr) == 0) return (0); @@ -2151,7 +2151,7 @@ char *interp; int i, notes, pagesize; uintptr_t addr, base_addr; - struct stat64 stbuf; + struct stat stbuf; void *phbuf, *php; size_t nbytes; #ifdef CONFIG_LINUX_CORE_SUPPORT @@ -2221,7 +2221,7 @@ /* * Fstat and open the core file and make sure it is a valid ELF core. */ - if (fstat64(P->asfd, &stbuf) == -1) { + if (fstat(P->asfd, &stbuf) == -1) { *perr = G_STRANGE; goto err; } @@ -2333,7 +2333,7 @@ /* * Advance the seek pointer to the start of the PT_NOTE data */ - if (lseek64(P->asfd, note_phdr.p_offset, SEEK_SET) == (off64_t)-1) { + if (lseek64(P->asfd, note_phdr.p_offset, SEEK_SET) == (off_t)-1) { dprintf("Pgrab_core: failed to lseek to PT_NOTE data\n"); *perr = G_STRANGE; goto err; @@ -2355,7 +2355,7 @@ */ for (nleft = note_phdr.p_filesz; nleft > 0; ) { Elf64_Nhdr nhdr; - off64_t off, namesz, descsz; + off_t off, namesz, descsz; /* * Although <sys/elf.h> defines both Elf32_Nhdr and Elf64_Nhdr @@ -2377,9 +2377,9 @@ * descriptions can assume only 4-byte alignment. We ignore * the name field and the padding to 4-byte alignment. */ - namesz = P2ROUNDUP((off64_t)nhdr.n_namesz, (off64_t)4); - - if (lseek64(P->asfd, namesz, SEEK_CUR) == (off64_t)-1) { + namesz = P2ROUNDUP((off_t)nhdr.n_namesz, (off_t)4); + + if (lseek64(P->asfd, namesz, SEEK_CUR) == (off_t)-1) { dprintf("failed to seek past name and padding\n"); *perr = G_STRANGE; goto err; @@ -2388,7 +2388,7 @@ dprintf("Note hdr n_type=%u n_namesz=%u n_descsz=%u\n", nhdr.n_type, nhdr.n_namesz, nhdr.n_descsz); - off = lseek64(P->asfd, (off64_t)0L, SEEK_CUR); + off = lseek64(P->asfd, (off_t)0L, SEEK_CUR); /* * Invoke the note handler function from our table @@ -2416,8 +2416,8 @@ /* * Seek past the current note data to the next Elf_Nhdr */ - descsz = P2ROUNDUP((off64_t)nhdr.n_descsz, (off64_t)4); - if (lseek64(P->asfd, off + descsz, SEEK_SET) == (off64_t)-1) { + descsz = P2ROUNDUP((off_t)nhdr.n_descsz, (off_t)4); + if (lseek64(P->asfd, off + descsz, SEEK_SET) == (off_t)-1) { dprintf("Pgrab_core: failed to seek to next nhdr\n"); *perr = G_STRANGE; goto err; @@ -2721,7 +2721,7 @@ { int fd, oflag = (gflag & PGRAB_RDONLY) ? O_RDONLY : O_RDWR; - if ((fd = open64(core, oflag)) >= 0) + if ((fd = open(core, oflag)) >= 0) return (Pfgrab_core(fd, aout, perr)); if (errno != ENOENT)
--- a/usr/src/lib/libproc/common/Pfdinfo.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/Pfdinfo.c Tue Mar 12 00:28:57 2019 +0200 @@ -106,7 +106,7 @@ fd_info_t *fip; prfdinfo_t *info; int len; - struct stat64 stat; + struct stat stat; if (!isdigit(ent->d_name[0])) continue; @@ -117,7 +117,7 @@ info = &fip->fd_info; info->pr_fd = fd; - if (pr_fstat64(P, fd, &stat) == 0) { + if (pr_fstat(P, fd, &stat) == 0) { info->pr_mode = stat.st_mode; info->pr_uid = stat.st_uid; info->pr_gid = stat.st_gid;
--- a/usr/src/lib/libproc/common/Pgcore.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/Pgcore.c Tue Mar 12 00:28:57 2019 +0200 @@ -79,9 +79,9 @@ typedef struct { struct ps_prochandle *P; int pgc_fd; - off64_t *pgc_poff; - off64_t *pgc_soff; - off64_t *pgc_doff; + off_t *pgc_poff; + off_t *pgc_soff; + off_t *pgc_doff; core_content_t pgc_content; void *pgc_chunk; size_t pgc_chunksz; @@ -91,11 +91,11 @@ typedef struct { int fd_fd; - off64_t *fd_doff; + off_t *fd_doff; } fditer_t; static int -gc_pwrite64(int fd, const void *buf, size_t len, off64_t off) +gc_pwrite64(int fd, const void *buf, size_t len, off_t off) { int err; @@ -423,7 +423,7 @@ #endif /* _LP64 */ static int -write_note(int fd, uint_t type, const void *desc, size_t descsz, off64_t *offp) +write_note(int fd, uint_t type, const void *desc, size_t descsz, off_t *offp) { /* * Note headers are the same regardless of the data model of the @@ -964,7 +964,7 @@ int write_shstrtab(struct ps_prochandle *P, pgcore_t *pgc) { - off64_t off = *pgc->pgc_doff; + off_t off = *pgc->pgc_doff; size_t size = 0; shstrtab_t *s = &pgc->pgc_shstrtab; int i, ndx; @@ -1042,7 +1042,7 @@ char zonename[ZONENAME_MAX]; int platlen = -1; pgcore_t pgc; - off64_t poff, soff, doff, boff; + off_t poff, soff, doff, boff; struct utsname uts; uint_t nphdrs, nshdrs;
--- a/usr/src/lib/libproc/common/Pidle.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/Pidle.c Tue Mar 12 00:28:57 2019 +0200 @@ -48,7 +48,7 @@ map_info_t *mp; uintptr_t mapoff; ssize_t len; - off64_t off; + off_t off; if ((mp = Paddr2mptr(P, addr)) == NULL) break; @@ -163,7 +163,7 @@ int fd; int i; - if ((fd = open64(fname, O_RDONLY)) < 0) { + if ((fd = open(fname, O_RDONLY)) < 0) { dprintf("couldn't open file"); *perr = (errno == ENOENT) ? G_NOEXEC : G_STRANGE; return (NULL);
--- a/usr/src/lib/libproc/common/Pzone.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/Pzone.c Tue Mar 12 00:28:57 2019 +0200 @@ -52,7 +52,7 @@ /* * Parameters of the lofs lookup cache. */ -static struct stat64 lofs_mstat; /* last stat() of MNTTAB */ +static struct stat lofs_mstat; /* last stat() of MNTTAB */ static struct lofs_mnttab { /* linked list of all lofs mount points */ struct lofs_mnttab *l_next; char *l_special; /* extracted from MNTTAB */ @@ -311,7 +311,7 @@ Plofspath(const char *path, char *s, size_t n) { char tmp[PATH_MAX + 1]; - struct stat64 statb; + struct stat statb; const char *special; char *p, *p2; int rv; @@ -338,7 +338,7 @@ * If /etc/mnttab has been modified since the last time * we looked, then rebuild the lofs lookup cache. */ - if (stat64(MNTTAB, &statb) == 0 && + if (stat(MNTTAB, &statb) == 0 && (statb.st_mtim.tv_sec != lofs_mstat.st_mtim.tv_sec || statb.st_mtim.tv_nsec != lofs_mstat.st_mtim.tv_nsec || statb.st_ctim.tv_sec != lofs_mstat.st_ctim.tv_sec || @@ -519,7 +519,7 @@ { char zroot[PATH_MAX], zpath[PATH_MAX], tmp[PATH_MAX], link[PATH_MAX]; path_node_t *pn_stack = NULL, *pn_links = NULL, *pn; - struct stat64 sb; + struct stat sb; char *p; int i, rv; @@ -650,13 +650,13 @@ */ (void) strlcpy(tmp, zroot, sizeof (tmp)); (void) strlcat(tmp, zpath, sizeof (tmp)); - if (lstat64(tmp, &sb) != 0) { + if (lstat(tmp, &sb) != 0) { pn_free2(&pn_stack, &pn_links); return (NULL); } if (!S_ISLNK(sb.st_mode)) { /* - * Since the lstat64() above succeeded we know that + * Since the lstat() above succeeded we know that * zpath exists, since this is not a symlink loop * around and check the next path component. */
--- a/usr/src/lib/libproc/common/libproc.h Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/libproc.h Tue Mar 12 00:28:57 2019 +0200 @@ -360,11 +360,6 @@ extern int pr_stat(struct ps_prochandle *, const char *, struct stat *); extern int pr_lstat(struct ps_prochandle *, const char *, struct stat *); extern int pr_fstat(struct ps_prochandle *, int, struct stat *); -extern int pr_stat64(struct ps_prochandle *, const char *, - struct stat64 *); -extern int pr_lstat64(struct ps_prochandle *, const char *, - struct stat64 *); -extern int pr_fstat64(struct ps_prochandle *, int, struct stat64 *); extern int pr_statvfs(struct ps_prochandle *, const char *, statvfs_t *); extern int pr_fstatvfs(struct ps_prochandle *, int, statvfs_t *); extern projid_t pr_getprojid(struct ps_prochandle *Pr); @@ -382,12 +377,6 @@ int, const struct rlimit *); extern int pr_setprojrctl(struct ps_prochandle *, const char *, rctlblk_t *, size_t, int); -#if defined(_LARGEFILE64_SOURCE) -extern int pr_getrlimit64(struct ps_prochandle *, - int, struct rlimit64 *); -extern int pr_setrlimit64(struct ps_prochandle *, - int, const struct rlimit64 *); -#endif /* _LARGEFILE64_SOURCE */ extern int pr_lwp_exit(struct ps_prochandle *); extern int pr_exit(struct ps_prochandle *, int); extern int pr_waitid(struct ps_prochandle *,
--- a/usr/src/lib/libproc/common/mapfile-vers Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/mapfile-vers Tue Mar 12 00:28:57 2019 +0200 @@ -174,7 +174,6 @@ pr_exit; pr_fcntl; pr_fstat; - pr_fstat64; pr_fstatvfs; pr_getitimer; pr_getpeername; @@ -182,7 +181,6 @@ pr_getprojid; pr_getrctl; pr_getrlimit; - pr_getrlimit64; pr_getsockname; pr_getsockopt; pr_gettaskid; @@ -192,7 +190,6 @@ pr_llseek; pr_lseek; pr_lstat; - pr_lstat64; pr_lwp_exit; pr_memcntl; pr_meminfo; @@ -237,11 +234,9 @@ pr_setprojrctl; pr_setrctl; pr_setrlimit; - pr_setrlimit64; pr_settaskid; pr_sigaction; pr_stat; - pr_stat64; pr_statvfs; pr_unlink; pr_waitid;
--- a/usr/src/lib/libproc/common/pr_getrlimit.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/pr_getrlimit.c Tue Mar 12 00:28:57 2019 +0200 @@ -64,14 +64,7 @@ adp->arg_inout = AI_OUTPUT; adp->arg_size = sizeof (*rlp); -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - sysnum = SYS_getrlimit64; - else - sysnum = SYS_getrlimit; -#else /* _LP64 */ sysnum = SYS_getrlimit; -#endif /* _LP64 */ error = Psyscall(Pr, &rval, sysnum, 2, &argd[0]); @@ -112,14 +105,7 @@ adp->arg_inout = AI_INPUT; adp->arg_size = sizeof (*rlp); -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - sysnum = SYS_setrlimit64; - else - sysnum = SYS_setrlimit; -#else /* _LP64 */ sysnum = SYS_setrlimit; -#endif /* _LP64 */ error = Psyscall(Pr, &rval, sysnum, 2, &argd[0]); @@ -129,99 +115,3 @@ } return (rval.sys_rval1); } - -/* - * getrlimit64() system call -- executed by subject process. - */ -int -pr_getrlimit64(struct ps_prochandle *Pr, - int resource, struct rlimit64 *rlp) -{ - sysret_t rval; /* return value from getrlimit() */ - argdes_t argd[2]; /* arg descriptors for getrlimit() */ - argdes_t *adp; - int sysnum; - int error; - - if (Pr == NULL) /* no subject process */ - return (getrlimit64(resource, rlp)); - - adp = &argd[0]; /* resource argument */ - adp->arg_value = resource; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - - adp++; /* rlp argument */ - adp->arg_value = 0; - adp->arg_object = rlp; - adp->arg_type = AT_BYREF; - adp->arg_inout = AI_OUTPUT; - adp->arg_size = sizeof (*rlp); - -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - sysnum = SYS_getrlimit64; - else - sysnum = SYS_getrlimit; -#else /* _LP64 */ - sysnum = SYS_getrlimit64; -#endif /* _LP64 */ - - error = Psyscall(Pr, &rval, sysnum, 2, &argd[0]); - - if (error) { - errno = (error > 0)? error : ENOSYS; - return (-1); - } - return (rval.sys_rval1); -} - -/* - * setrlimit64() system call -- executed by subject process. - */ -int -pr_setrlimit64(struct ps_prochandle *Pr, - int resource, const struct rlimit64 *rlp) -{ - sysret_t rval; /* return value from setrlimit() */ - argdes_t argd[2]; /* arg descriptors for setrlimit() */ - argdes_t *adp; - int sysnum; - int error; - - if (Pr == NULL) /* no subject process */ - return (setrlimit64(resource, rlp)); - - adp = &argd[0]; /* resource argument */ - adp->arg_value = resource; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - - adp++; /* rlp argument */ - adp->arg_value = 0; - adp->arg_object = (void *)rlp; - adp->arg_type = AT_BYREF; - adp->arg_inout = AI_INPUT; - adp->arg_size = sizeof (*rlp); - -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - sysnum = SYS_setrlimit64; - else - sysnum = SYS_setrlimit; -#else /* _LP64 */ - sysnum = SYS_setrlimit64; -#endif /* _LP64 */ - - error = Psyscall(Pr, &rval, sysnum, 2, &argd[0]); - - if (error) { - errno = (error > 0)? error : ENOSYS; - return (-1); - } - return (rval.sys_rval1); -}
--- a/usr/src/lib/libproc/common/pr_stat.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/pr_stat.c Tue Mar 12 00:28:57 2019 +0200 @@ -35,33 +35,6 @@ #include <sys/sysmacros.h> #include "libproc.h" -#ifdef _LP64 -/* - * in case of 64-bit *stat() and *stat64 library call and 32-bit subject - * process convert 64-bit struct stat/stat64 into 32-bit struct stat64 - */ -static void -stat64_32_to_n(struct stat64_32 *src, struct stat *dest) -{ - (void) memset(dest, 0, sizeof (*dest)); - dest->st_dev = DEVEXPL(src->st_dev); - dest->st_ino = (ino_t)src->st_ino; - dest->st_mode = (mode_t)src->st_mode; - dest->st_nlink = (nlink_t)src->st_nlink; - dest->st_uid = (uid_t)src->st_uid; - dest->st_gid = (gid_t)src->st_gid; - dest->st_rdev = DEVEXPL(src->st_rdev); - dest->st_size = (off_t)src->st_size; - TIMESPEC32_TO_TIMESPEC(&dest->st_atim, &src->st_atim); - TIMESPEC32_TO_TIMESPEC(&dest->st_mtim, &src->st_mtim); - TIMESPEC32_TO_TIMESPEC(&dest->st_ctim, &src->st_ctim); - dest->st_blksize = (blksize_t)src->st_blksize; - dest->st_blocks = (blkcnt_t)src->st_blocks; - (void) memcpy(dest->st_fstype, src->st_fstype, - sizeof (dest->st_fstype)); -} -#endif /* _LP64 */ - /* * stat() system call -- executed by subject process */ @@ -71,22 +44,12 @@ sysret_t rval; /* return value from stat() */ argdes_t argd[4]; /* arg descriptors for fstatat() */ argdes_t *adp = &argd[0]; /* first argument */ - int syscall; /* SYS_fstatat or SYS_fstatat64 */ + int syscall = SYS_fstatat; int error; -#ifdef _LP64 - struct stat64_32 statb64_32; -#endif /* _LP64 */ if (Pr == NULL) /* no subject process */ return (stat(path, buf)); - if (Pstatus(Pr)->pr_dmodel != PR_MODEL_NATIVE) { - /* 64-bit process controls 32-bit subject process */ - syscall = SYS_fstatat64; - } else { - syscall = SYS_fstatat; - } - adp->arg_value = AT_FDCWD; adp->arg_object = NULL; adp->arg_type = AT_BYVAL; @@ -104,18 +67,8 @@ adp->arg_value = 0; adp->arg_type = AT_BYREF; adp->arg_inout = AI_OUTPUT; -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - adp->arg_object = &statb64_32; - adp->arg_size = sizeof (statb64_32); - } else { - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); - } -#else /* _LP64 */ adp->arg_object = buf; adp->arg_size = sizeof (*buf); -#endif /* _LP64 */ adp++; /* move to flags argument */ adp->arg_value = 0; @@ -130,10 +83,6 @@ errno = (error > 0)? error : ENOSYS; return (-1); } -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - stat64_32_to_n(&statb64_32, buf); -#endif /* _LP64 */ return (0); } @@ -146,22 +95,12 @@ sysret_t rval; /* return value from stat() */ argdes_t argd[4]; /* arg descriptors for fstatat() */ argdes_t *adp = &argd[0]; /* first argument */ - int syscall; /* SYS_fstatat or SYS_fstatat64 */ + int syscall = SYS_fstatat; int error; -#ifdef _LP64 - struct stat64_32 statb64_32; -#endif /* _LP64 */ if (Pr == NULL) /* no subject process */ return (lstat(path, buf)); - if (Pstatus(Pr)->pr_dmodel != PR_MODEL_NATIVE) { - /* 64-bit process controls 32-bit subject process */ - syscall = SYS_fstatat64; - } else { - syscall = SYS_fstatat; - } - adp->arg_value = AT_FDCWD; adp->arg_object = NULL; adp->arg_type = AT_BYVAL; @@ -179,18 +118,8 @@ adp->arg_value = 0; adp->arg_type = AT_BYREF; adp->arg_inout = AI_OUTPUT; -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - adp->arg_object = &statb64_32; - adp->arg_size = sizeof (statb64_32); - } else { - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); - } -#else /* _LP64 */ adp->arg_object = buf; adp->arg_size = sizeof (*buf); -#endif /* _LP64 */ adp++; /* move to flags argument */ adp->arg_value = AT_SYMLINK_NOFOLLOW; @@ -205,10 +134,6 @@ errno = (error > 0)? error : ENOSYS; return (-1); } -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - stat64_32_to_n(&statb64_32, buf); -#endif /* _LP64 */ return (0); } @@ -221,22 +146,12 @@ sysret_t rval; /* return value from stat() */ argdes_t argd[4]; /* arg descriptors for fstatat() */ argdes_t *adp = &argd[0]; /* first argument */ - int syscall; /* SYS_fstatat or SYS_fstatat64 */ + int syscall = SYS_fstatat; int error; -#ifdef _LP64 - struct stat64_32 statb64_32; -#endif /* _LP64 */ if (Pr == NULL) /* no subject process */ return (fstat(fd, buf)); - if (Pstatus(Pr)->pr_dmodel != PR_MODEL_NATIVE) { - /* 64-bit process controls 32-bit subject process */ - syscall = SYS_fstatat64; - } else { - syscall = SYS_fstatat; - } - adp->arg_value = fd; adp->arg_object = NULL; adp->arg_type = AT_BYVAL; @@ -254,97 +169,8 @@ adp->arg_value = 0; adp->arg_type = AT_BYREF; adp->arg_inout = AI_OUTPUT; -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - adp->arg_object = &statb64_32; - adp->arg_size = sizeof (statb64_32); - } else { - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); - } -#else /* _LP64 */ adp->arg_object = buf; adp->arg_size = sizeof (*buf); -#endif /* _LP64 */ - adp++; /* move to flags argument */ - - adp->arg_value = 0; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - - error = Psyscall(Pr, &rval, syscall, 4, &argd[0]); - - if (error) { - errno = (error > 0)? error : ENOSYS; - return (-1); - } -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - stat64_32_to_n(&statb64_32, buf); -#endif /* _LP64 */ - return (0); -} - -/* - * stat64() system call -- executed by subject process - */ -int -pr_stat64(struct ps_prochandle *Pr, const char *path, struct stat64 *buf) -{ - sysret_t rval; /* return value from stat() */ - argdes_t argd[4]; /* arg descriptors for fstatat() */ - argdes_t *adp = &argd[0]; /* first argument */ - int syscall; /* SYS_fstatat or SYS_fstatat64 */ - int error; -#ifdef _LP64 - struct stat64_32 statb64_32; -#endif /* _LP64 */ - - if (Pr == NULL) /* no subject process */ - return (stat64(path, buf)); - - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - /* - * 32-bit native and - * 64-bit process controls 32-bit subject process - */ - syscall = SYS_fstatat64; - } else { - /* 64-bit native */ - syscall = SYS_fstatat; - } - - adp->arg_value = AT_FDCWD; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - adp++; /* move to path argument */ - - adp->arg_value = 0; - adp->arg_object = (void *)path; - adp->arg_type = AT_BYREF; - adp->arg_inout = AI_INPUT; - adp->arg_size = strlen(path) + 1; - adp++; /* move to buffer argument */ - - adp->arg_value = 0; - adp->arg_type = AT_BYREF; - adp->arg_inout = AI_OUTPUT; -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - adp->arg_object = &statb64_32; - adp->arg_size = sizeof (statb64_32); - } else { - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); - } -#else /* _LP64 */ - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); -#endif /* _LP64 */ adp++; /* move to flags argument */ adp->arg_value = 0; @@ -359,167 +185,5 @@ errno = (error > 0)? error : ENOSYS; return (-1); } -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - stat64_32_to_n(&statb64_32, (struct stat *)buf); -#endif /* _LP64 */ return (0); } - -/* - * lstat64() system call -- executed by subject process - */ -int -pr_lstat64(struct ps_prochandle *Pr, const char *path, struct stat64 *buf) -{ - sysret_t rval; /* return value from stat() */ - argdes_t argd[4]; /* arg descriptors for fstatat() */ - argdes_t *adp = &argd[0]; /* first argument */ - int syscall; /* SYS_fstatat or SYS_fstatat64 */ - int error; -#ifdef _LP64 - struct stat64_32 statb64_32; -#endif /* _LP64 */ - - if (Pr == NULL) /* no subject process */ - return (lstat64(path, buf)); - - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - /* - * 32-bit native and - * 64-bit process controls 32-bit subject process - */ - syscall = SYS_fstatat64; - } else { - /* 64-bit native */ - syscall = SYS_fstatat; - } - - adp->arg_value = AT_FDCWD; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - adp++; /* move to path argument */ - - adp->arg_value = 0; - adp->arg_object = (void *)path; - adp->arg_type = AT_BYREF; - adp->arg_inout = AI_INPUT; - adp->arg_size = strlen(path) + 1; - adp++; /* move to buffer argument */ - - adp->arg_value = 0; - adp->arg_type = AT_BYREF; - adp->arg_inout = AI_OUTPUT; -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - adp->arg_object = &statb64_32; - adp->arg_size = sizeof (statb64_32); - } else { - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); - } -#else /* _LP64 */ - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); -#endif /* _LP64 */ - adp++; /* move to flags argument */ - - adp->arg_value = AT_SYMLINK_NOFOLLOW; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - - error = Psyscall(Pr, &rval, syscall, 4, &argd[0]); - - if (error) { - errno = (error > 0)? error : ENOSYS; - return (-1); - } -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - stat64_32_to_n(&statb64_32, (struct stat *)buf); -#endif /* _LP64 */ - return (0); -} - -/* - * fstat64() system call -- executed by subject process - */ -int -pr_fstat64(struct ps_prochandle *Pr, int fd, struct stat64 *buf) -{ - sysret_t rval; /* return value from stat() */ - argdes_t argd[4]; /* arg descriptors for fstatat() */ - argdes_t *adp = &argd[0]; /* first argument */ - int syscall; /* SYS_fstatat or SYS_fstatat64 */ - int error; -#ifdef _LP64 - struct stat64_32 statb64_32; -#endif /* _LP64 */ - - if (Pr == NULL) /* no subject process */ - return (fstat64(fd, buf)); - - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - /* - * 32-bit native and - * 64-bit process controls 32-bit subject process - */ - syscall = SYS_fstatat64; - } else { - /* 64-bit native */ - syscall = SYS_fstatat; - } - - adp->arg_value = fd; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - adp++; /* move to path argument */ - - adp->arg_value = 0; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - adp++; /* move to buffer argument */ - - adp->arg_value = 0; - adp->arg_type = AT_BYREF; - adp->arg_inout = AI_OUTPUT; -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) { - adp->arg_object = &statb64_32; - adp->arg_size = sizeof (statb64_32); - } else { - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); - } -#else /* _LP64 */ - adp->arg_object = buf; - adp->arg_size = sizeof (*buf); -#endif /* _LP64 */ - adp++; /* move to flags argument */ - - adp->arg_value = 0; - adp->arg_object = NULL; - adp->arg_type = AT_BYVAL; - adp->arg_inout = AI_INPUT; - adp->arg_size = 0; - - error = Psyscall(Pr, &rval, syscall, 4, &argd[0]); - - if (error) { - errno = (error > 0)? error : ENOSYS; - return (-1); - } -#ifdef _LP64 - if (Pstatus(Pr)->pr_dmodel == PR_MODEL_ILP32) - stat64_32_to_n(&statb64_32, (struct stat *)buf); -#endif /* _LP64 */ - return (0); -}
--- a/usr/src/lib/libproc/common/proc_arg.c Tue Mar 12 00:12:54 2019 +0200 +++ b/usr/src/lib/libproc/common/proc_arg.c Tue Mar 12 00:28:57 2019 +0200 @@ -47,7 +47,7 @@ */ char *path = alloca(strlen(arg) + strlen(procfs_path) + 9); - struct stat64 st; + struct stat st; int fd; if (strchr(arg, '/') == NULL) { @@ -63,8 +63,8 @@ * Attempt to open the psinfo file, and return the fd if we can * confirm this is a regular file provided by /proc. */ - if ((fd = open64(path, O_RDONLY)) >= 0) { - if (fstat64(fd, &st) != 0 || !S_ISREG(st.st_mode) || + if ((fd = open(path, O_RDONLY)) >= 0) { + if (fstat(fd, &st) != 0 || !S_ISREG(st.st_mode) || strcmp(st.st_fstype, "proc") != 0) { (void) close(fd); fd = -1; @@ -91,7 +91,7 @@ * Attempt to open the core file, and return the fd if we can confirm * this is an ELF file of type ET_CORE. */ - if ((fd = open64(arg, O_RDONLY)) >= 0) { + if ((fd = open(arg, O_RDONLY)) >= 0) { if (read(fd, &ehdr, sizeof (ehdr)) != sizeof (ehdr)) { (void) close(fd); fd = -1;