From a140cc724afa044bfb0151bea50005d60523388068422011ff2c40bbf9f17b8c Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Wed, 22 Jun 2011 11:36:15 +0000 Subject: [PATCH 1/4] . OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=36 --- .gitattributes | 2 + _service:download_files:psmisc-22.14.tar.gz | 3 + _service:download_files:psmisc-22.14.tar.gz.1 | 3 + _service:format_spec_file:psmisc.spec | 105 ++ psmisc-22.12-leaks.patch | 269 ----- psmisc-22.12-nfs4fuser.patch.old.bz2 | 3 - psmisc-22.12-writeonly.patch | 129 --- psmisc-22.13-nfs4fuser.patch | 933 ------------------ psmisc-22.13-peekfd-segv.patch | 13 - psmisc-22.13.tar.bz2 | 3 - psmisc-22.14-toomuch.dif | 255 +++++ psmisc-22.13.dif => psmisc-22.14.dif | 0 psmisc-22.14.tar.gz | 3 + psmisc.changes | 24 + psmisc.spec | 24 +- 15 files changed, 404 insertions(+), 1365 deletions(-) create mode 100644 _service:download_files:psmisc-22.14.tar.gz create mode 100644 _service:download_files:psmisc-22.14.tar.gz.1 create mode 100644 _service:format_spec_file:psmisc.spec delete mode 100644 psmisc-22.12-leaks.patch delete mode 100644 psmisc-22.12-nfs4fuser.patch.old.bz2 delete mode 100644 psmisc-22.12-writeonly.patch delete mode 100644 psmisc-22.13-nfs4fuser.patch delete mode 100644 psmisc-22.13-peekfd-segv.patch delete mode 100644 psmisc-22.13.tar.bz2 create mode 100644 psmisc-22.14-toomuch.dif rename psmisc-22.13.dif => psmisc-22.14.dif (100%) create mode 100644 psmisc-22.14.tar.gz diff --git a/.gitattributes b/.gitattributes index 9b03811..3997efa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,3 +21,5 @@ *.xz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text +## Specific LFS patterns +_service:download_files:psmisc-22.14.tar.gz.1 filter=lfs diff=lfs merge=lfs -text diff --git a/_service:download_files:psmisc-22.14.tar.gz b/_service:download_files:psmisc-22.14.tar.gz new file mode 100644 index 0000000..4571830 --- /dev/null +++ b/_service:download_files:psmisc-22.14.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22bbf4561837af475c0d8d14e3b9cab453998c787212c107fac7faf2f281e26e +size 382024 diff --git a/_service:download_files:psmisc-22.14.tar.gz.1 b/_service:download_files:psmisc-22.14.tar.gz.1 new file mode 100644 index 0000000..4571830 --- /dev/null +++ b/_service:download_files:psmisc-22.14.tar.gz.1 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22bbf4561837af475c0d8d14e3b9cab453998c787212c107fac7faf2f281e26e +size 382024 diff --git a/_service:format_spec_file:psmisc.spec b/_service:format_spec_file:psmisc.spec new file mode 100644 index 0000000..29c2ebb --- /dev/null +++ b/_service:format_spec_file:psmisc.spec @@ -0,0 +1,105 @@ +# +# spec file for package psmisc +# +# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# norootforbuild + + +Name: psmisc +BuildRequires: gcc-c++ glibc-devel ncurses-devel +BuildRequires: libselinux-devel +Url: http://sourceforge.net/projects/psmisc/ +License: GPLv2+ +Group: System/Monitoring +PreReq: %fillup_prereq %insserv_prereq +Version: 22.14 +Release: 1 +Provides: ps:/usr/bin/killall +Summary: Utilities for managing processes on your system +Source: http://sourceforge.net/projects/psmisc/files/psmisc/%{name}-%{version}.tar.gz +Patch0: %name-22.14.dif +Patch1: %name-22.12-tigetstr.patch +Patch2: %name-22.12-pstree_overflow.patch +Patch3: %name-22.12-pstree.patch +Patch4: %name-22.14-toomuch.dif + +BuildRoot: %{_tmppath}/%{name}-%{version}-build +%define nopeek s390 s390x ia64 %sparc hppa + + +%description +The psmisc package contains utilities for managing processes on your +system: pstree, killall and fuser. The pstree command displays a tree +structure of all of the running processes on your system. The killall +command sends a specified signal (SIGTERM if nothing is specified) to +processes identified by name. The fuser command identifies the PIDs of +processes that are using specified files or filesystems. + +%prep +%setup -q +%patch1 -p0 -b .tigetstr +%patch2 -p0 -b .pstreeovfl +%patch3 -p0 -b .pstree +%patch4 -p0 -b .2much +%patch0 -p0 -b .0 + + +%build +autoreconf -fi +CFLAGS="-D_GNU_SOURCE ${RPM_OPT_FLAGS} -pipe" +CXXFLAGS="$CFLAGS" +CC=gcc +CXX=g++ +export CFLAGS CXXFLAGS CC CXX +sh ./configure --prefix=%{_prefix} --mandir=%{_mandir} --enable-selinux +make %{?_smp_mflags} CFLAGS="$CFLAGS" "CC=$CC" + + +%install +make DESTDIR=$RPM_BUILD_ROOT install +mkdir -p $RPM_BUILD_ROOT/bin/ +mv $RPM_BUILD_ROOT/usr/bin/fuser $RPM_BUILD_ROOT/bin/ +%ifarch %nopeek +rm -f $RPM_BUILD_ROOT%{_mandir}/man1/peekfd.1* +%endif +%find_lang psmisc + + +%clean +rm -rf $RPM_BUILD_ROOT + + +%files -f psmisc.lang +%defattr (-,root,root,755) +/bin/fuser +%{_bindir}/killall +%ifnarch %nopeek +%{_bindir}/peekfd +%endif +%{_bindir}/prtstat +%{_bindir}/pstree +%{_bindir}/pstree.x11 +%{_mandir}/man1/fuser.1* +%{_mandir}/man1/killall.1* +%ifnarch %nopeek +%{_mandir}/man1/peekfd.1* +%endif +%{_mandir}/man1/prtstat.1* +%{_mandir}/man1/pstree.1* + + + +%changelog diff --git a/psmisc-22.12-leaks.patch b/psmisc-22.12-leaks.patch deleted file mode 100644 index bd72c24..0000000 --- a/psmisc-22.12-leaks.patch +++ /dev/null @@ -1,269 +0,0 @@ ---- src/fuser.c -+++ src/fuser.c 2010-07-13 14:42:02.762926098 +0000 -@@ -148,18 +148,12 @@ scan_procs(struct names *names_head, str - { - DIR *topproc_dir; - struct dirent *topproc_dent; -- char *fd_dirpath, *fd_pathname; - struct inode_list *ino_tmp; - struct device_list *dev_tmp; - pid_t pid, my_pid; - uid_t uid; - struct stat *cwd_stat, *exe_stat, *root_stat; - -- if ((fd_dirpath = malloc(MAX_PATHNAME)) == NULL) -- return; -- if ((fd_pathname = malloc(MAX_PATHNAME)) == NULL) -- return; -- - if ((topproc_dir = opendir("/proc")) == NULL) { - fprintf(stderr, _("Cannot open /proc directory: %s\n"), - strerror(errno)); -@@ -219,6 +213,9 @@ scan_procs(struct names *names_head, str - } - } - } -+ if (root_stat) free(root_stat); -+ if (cwd_stat) free(cwd_stat); -+ if (exe_stat) free(exe_stat); - check_dir(pid, "lib", dev_head, ino_head, uid, ACCESS_MMAP, - sockets, netdev); - check_dir(pid, "mmap", dev_head, ino_head, uid, ACCESS_MMAP, -@@ -237,10 +234,9 @@ add_inode(struct inode_list **ino_list, - { - struct inode_list *ino_tmp, *ino_head; - -- ino_head = *ino_list; -- -- if ((ino_tmp = malloc(sizeof(struct inode_list))) == NULL) -+ if ((ino_tmp = (struct inode_list*)malloc(sizeof(struct inode_list))) == NULL) - return; -+ ino_head = *ino_list; - ino_tmp->name = this_name; - ino_tmp->device = device; - ino_tmp->inode = inode; -@@ -254,10 +250,10 @@ add_device(struct device_list **dev_list - struct device_list *dev_tmp, *dev_head; - - /*printf("Adding device %s %d\n", this_name->filename, device); */ -- dev_head = *dev_list; - -- if ((dev_tmp = malloc(sizeof(struct device_list))) == NULL) -+ if ((dev_tmp = (struct device_list*)malloc(sizeof(struct device_list))) == NULL) - return; -+ dev_head = *dev_list; - dev_tmp->name = this_name; - dev_tmp->device = device; - dev_tmp->next = dev_head; -@@ -271,10 +267,9 @@ add_ip_conn(struct ip_connections **ip_l - { - struct ip_connections *ip_tmp, *ip_head; - -- ip_head = *ip_list; -- -- if ((ip_tmp = malloc(sizeof(struct ip_connections))) == NULL) -+ if ((ip_tmp = (struct ip_connections*)malloc(sizeof(struct ip_connections))) == NULL) - return; -+ ip_head = *ip_list; - ip_tmp->name = this_name; - ip_tmp->lcl_port = lcl_port; - ip_tmp->rmt_port = rmt_port; -@@ -292,10 +287,9 @@ add_ip6_conn(struct ip6_connections **ip - { - struct ip6_connections *ip_tmp, *ip_head; - -- ip_head = *ip_list; -- -- if ((ip_tmp = malloc(sizeof(struct ip6_connections))) == NULL) -+ if ((ip_tmp = (struct ip6_connections*)malloc(sizeof(struct ip6_connections))) == NULL) - return; -+ ip_head = *ip_list; - ip_tmp->name = this_name; - ip_tmp->lcl_port = lcl_port; - ip_tmp->rmt_port = rmt_port; -@@ -326,7 +320,7 @@ add_matched_proc(struct names *name_list - } - } - /* Not found */ -- if ((pptr = malloc(sizeof(struct procs))) == NULL) { -+ if ((pptr = (struct procs*)malloc(sizeof(struct procs))) == NULL) { - fprintf(stderr, - _("Cannot allocate memory for matched proc: %s\n"), - strerror(errno)); -@@ -339,10 +333,13 @@ add_matched_proc(struct names *name_list - pptr->next = NULL; - /* set command name */ - pptr->command = NULL; -+ -+ fp = NULL; -+ pathname = NULL; - if ((asprintf(&pathname, "/proc/%d/stat", pid) > 0) && - ((fp = fopen(pathname, "r")) != NULL) && - (fscanf(fp, "%*d (%100[^)]", cmdname) == 1)) -- if ((pptr->command = malloc(MAX_CMDNAME + 1)) != NULL) { -+ if ((pptr->command = (char*)malloc(MAX_CMDNAME + 1)) != NULL) { - cmdlen = 0; - for (cptr = cmdname; cmdlen < MAX_CMDNAME && *cptr; - cptr++) { -@@ -359,6 +356,10 @@ add_matched_proc(struct names *name_list - name_list->matched_procs = pptr; - else - last_proc->next = pptr; -+ if (pathname) -+ free(pathname); -+ if (fp) -+ fclose(fp); - } - - /* Adds a knfsd etc process */ -@@ -680,7 +681,7 @@ find_net_sockets(struct inode_list **ino - } - - } -- return; -+ fclose(fp); - } - - #ifdef WITH_IPV6 -@@ -753,6 +754,7 @@ find_net6_sockets(struct inode_list **in - } - } - } -+ fclose(fp); - } - #endif - -@@ -1253,13 +1255,15 @@ static struct stat *get_pidstat(const pi - char pathname[256]; - struct stat *st; - -- if ((st = malloc(sizeof(struct stat))) == NULL) -+ if ((st = (struct stat*)malloc(sizeof(struct stat))) == NULL) - return NULL; - snprintf(pathname, 256, "/proc/%d/%s", pid, filename); - if (stat(pathname, st) != 0) -- return NULL; -- else -- return st; -+ goto out; -+ return st; -+out: -+ free(st); -+ return NULL; - } - - static void -@@ -1267,7 +1271,7 @@ check_dir(const pid_t pid, const char *d - struct inode_list *ino_head, const uid_t uid, const char access, - struct unixsocket_list *sockets, dev_t netdev) - { -- char *dirpath, *filepath; -+ char *dirpath = NULL, *filepath = NULL; - DIR *dirp; - struct dirent *direntry; - struct inode_list *ino_tmp; -@@ -1275,14 +1279,14 @@ check_dir(const pid_t pid, const char *d - struct unixsocket_list *sock_tmp; - struct stat st, lst; - -- if ((dirpath = malloc(MAX_PATHNAME)) == NULL) -- return; -- if ((filepath = malloc(MAX_PATHNAME)) == NULL) -- return; -+ if ((dirpath = (char*)malloc(MAX_PATHNAME)) == NULL) -+ goto out; -+ if ((filepath = (char*)malloc(MAX_PATHNAME)) == NULL) -+ goto out; - - snprintf(dirpath, MAX_PATHNAME, "/proc/%d/%s", pid, dirname); - if ((dirp = opendir(dirpath)) == NULL) -- return; -+ goto out; - while ((direntry = readdir(dirp)) != NULL) { - if (direntry->d_name[0] < '0' || direntry->d_name[0] > '9') - continue; -@@ -1341,6 +1345,11 @@ check_dir(const pid_t pid, const char *d - } - } /* while fd_dent */ - closedir(dirp); -+out: -+ if (dirpath) -+ free(dirpath); -+ if (filepath) -+ free(filepath); - } - - static void -@@ -1400,7 +1409,6 @@ void fill_unix_cache(struct unixsocket_l - { - FILE *fp; - char line[BUFSIZ]; -- char *scanned_path; - int scanned_inode; - struct stat st; - struct unixsocket_list *newsocket; -@@ -1411,24 +1419,38 @@ void fill_unix_cache(struct unixsocket_l - return; - } - while (fgets(line, BUFSIZ, fp) != NULL) { -+ char * path; -+ char * scanned_path = NULL; - if (sscanf(line, "%*x: %*x %*x %*x %*x %*d %d %as", -- &scanned_inode, &scanned_path) != 2) -+ &scanned_inode, &scanned_path) != 2) { -+ if (scanned_path) -+ free(scanned_path); - continue; -+ } -+ if (scanned_path == NULL) -+ continue; -+ path = scanned_path; -+ if (*scanned_path == '@') -+ scanned_path++; - if (stat(scanned_path, &st) < 0) { -- free(scanned_path); -+ free(path); - continue; - } -- if ((newsocket = -- malloc(sizeof(struct unixsocket_list))) == NULL) -+ if ((newsocket = (struct unixsocket_list*) -+ malloc(sizeof(struct unixsocket_list))) == NULL) { -+ free(path); - continue; -+ } - newsocket->sun_name = strdup(scanned_path); - newsocket->inode = st.st_ino; - newsocket->dev = st.st_dev; - newsocket->net_inode = scanned_inode; - newsocket->next = *unixsocket_head; - *unixsocket_head = newsocket; -+ free(path); - } /* while */ - -+ fclose(fp); - } - - #ifdef DEBUG -@@ -1567,6 +1589,7 @@ scan_knfsd(struct names *names_head, str - line); - } - } -+ fclose(fp); - } - - static void -@@ -1610,6 +1633,7 @@ scan_mounts(struct names *names_head, st - find_mountp); - } - } -+ fclose(fp); - } - - static void -@@ -1656,4 +1680,5 @@ scan_swaps(struct names *names_head, str - line); - } - } -+ fclose(fp); - } diff --git a/psmisc-22.12-nfs4fuser.patch.old.bz2 b/psmisc-22.12-nfs4fuser.patch.old.bz2 deleted file mode 100644 index dde1e39..0000000 --- a/psmisc-22.12-nfs4fuser.patch.old.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:37c986a604ebfc72ddeea7dde48a5ddb0c0d8bdd7d81147626157e098243024b -size 6533 diff --git a/psmisc-22.12-writeonly.patch b/psmisc-22.12-writeonly.patch deleted file mode 100644 index c1b05dc..0000000 --- a/psmisc-22.12-writeonly.patch +++ /dev/null @@ -1,129 +0,0 @@ ---- doc/fuser.1 -+++ doc/fuser.1 2010-07-13 13:19:57.000000000 +0000 -@@ -12,6 +12,7 @@ fuser \- identify processes using files - .RB [ \-k - .RB [ \-i ] - .RB [ \-M ] -+.RB [ \-w ] - .RB [ \- \fISIGNAL - ] ] - .IR name " ..." -@@ -102,6 +103,10 @@ Request will be fulfilled only if \fINAM - This is an invaluable seatbelt which prevents you from killing the machine - if \fINAME\fR happens to not be a filesystem. - .TP -+\fB\-w\fP -+Kill only processes which have write access. This option is -+silently ignored if \fB\-k\fP is not present too. -+.TP - \fB\-n \fISPACE\fR, \fB\-\-namespace\fR \fISPACE\fR - Select a different name space. The name spaces \fBfile\fR (file names, the - default), \fBudp\fR (local UDP ports), and \fBtcp\fR (local TCP ports) are ---- src/fuser.c -+++ src/fuser.c 2010-07-13 13:25:44.000000000 +0000 -@@ -75,7 +75,7 @@ static struct stat *get_pidstat(const op - static uid_t getpiduid(const pid_t pid); - static int print_matches(struct names *names_head, const opt_type opts, - const int sig_number); --static void kill_matched_proc(struct procs *pptr, const opt_type opts, -+static int kill_matched_proc(struct procs *pptr, const opt_type opts, - const int sig_number); - - /*int parse_mount(struct names *this_name, struct device_list **dev_list);*/ -@@ -127,6 +127,7 @@ static void usage(const char *errormsg) - " -SIGNAL send this signal instead of SIGKILL\n" - " -u,--user display user IDs\n" - " -v,--verbose verbose output\n" -+ " -w,--writeonly kill only processes with write access\n" - " -V,--version display version information\n")); - #ifdef WITH_IPV6 - fprintf(stderr, _( -@@ -1133,6 +1134,7 @@ int main(int argc, char *argv[]) - {"silent", 0, NULL, 's'}, - {"user", 0, NULL, 'u'}, - {"verbose", 0, NULL, 'v'}, -+ {"writeonly", 0, NULL, 'w'}, - {"version", 0, NULL, 'V'}, - #ifdef WITH_IPV6 - {"ipv4", 0, NULL, '4'}, -@@ -1244,6 +1246,9 @@ int main(int argc, char *argv[]) - case 'v': - opts |= OPT_VERBOSE; - break; -+ case 'w': -+ opts |= OPT_WRITE; -+ break; - case 'V': - print_version(); - return 0; -@@ -1406,6 +1411,7 @@ print_matches(struct names *names_head, - int len = 0; - struct passwd *pwent = NULL; - int have_match = 0; -+ int have_kill = 0; - int name_has_procs; - - for (nptr = names_head; nptr != NULL; nptr = nptr->next) { -@@ -1546,8 +1552,8 @@ print_matches(struct names *names_head, - } - } /* be silent */ - if (opts & OPT_KILL) -- kill_matched_proc(nptr->matched_procs, opts, -- sig_number); -+ have_kill = kill_matched_proc(nptr->matched_procs, -+ opts, sig_number); - - } /* next name */ - return (have_match == 1 ? 0 : 1); -@@ -1857,12 +1863,13 @@ static int ask(const pid_t pid) - } /* while */ - } - --static void -+static int - kill_matched_proc(struct procs *proc_head, const opt_type opts, - const int sig_number) - { - struct procs *pptr; - pid_t mypid; -+ int ret = 0; - - mypid = getpid(); - -@@ -1871,13 +1878,18 @@ kill_matched_proc(struct procs *proc_hea - continue; /* dont kill myself */ - if ( pptr->proc_type != PTYPE_NORMAL ) - continue; -+ if ((opts & OPT_WRITE) && ((pptr->access & ACCESS_FILEWR) == 0)) -+ continue; - if ((opts & OPT_INTERACTIVE) && (ask(pptr->pid) == 0)) - continue; - if ( kill(pptr->pid, sig_number) < 0) { - fprintf(stderr, _("Could not kill process %d: %s\n"), - pptr->pid, strerror(errno)); -+ continue; - } -+ ret = 1; - } -+ return ret; - } - - static dev_t find_net_dev(void) ---- src/fuser.h -+++ src/fuser.h 2010-07-13 13:26:15.000000000 +0000 -@@ -1,6 +1,6 @@ - - /* Option Flags */ --typedef unsigned char opt_type; -+typedef unsigned short opt_type; - - #define OPT_VERBOSE 1 - #define OPT_ALLFILES 2 -@@ -10,6 +10,7 @@ typedef unsigned char opt_type; - #define OPT_SILENT 32 - #define OPT_USER 64 - #define OPT_ISMOUNTPOINT 128 -+#define OPT_WRITE 256 - - struct procs { - pid_t pid; diff --git a/psmisc-22.13-nfs4fuser.patch b/psmisc-22.13-nfs4fuser.patch deleted file mode 100644 index 2c51add..0000000 --- a/psmisc-22.13-nfs4fuser.patch +++ /dev/null @@ -1,933 +0,0 @@ ---- src/fuser.c -+++ src/fuser.c 2011-02-09 09:39:51.116426890 +0000 -@@ -32,9 +32,11 @@ - #include - #include - #include -+#include - #include - #include - #include -+#include - #include - #include - #include -@@ -45,6 +47,7 @@ - #include - #include - #include -+#include - - #include "fuser.h" - #include "signals.h" -@@ -95,6 +98,16 @@ static void debug_match_lists(struct nam - struct device_list *dev_head); - #endif - -+#ifdef _LISTS_H -+static void clear_mntinfo(void) __attribute__((__destructor__)); -+static void init_mntinfo(void) __attribute__((__constructor__)); -+static dev_t device(const char *path); -+#endif -+static char *expandpath(const char *path); -+ -+typedef int (*stat_t)(const char*, struct stat*); -+static int timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds); -+ - static void usage(const char *errormsg) - { - if (errormsg != NULL) -@@ -152,7 +165,7 @@ scan_procs(struct names *names_head, str - struct device_list *dev_tmp; - pid_t pid, my_pid; - uid_t uid; -- struct stat *cwd_stat, *exe_stat, *root_stat; -+ int dfd; - - if ((topproc_dir = opendir("/proc")) == NULL) { - fprintf(stderr, _("Cannot open /proc directory: %s\n"), -@@ -160,7 +173,17 @@ scan_procs(struct names *names_head, str - exit(1); - } - my_pid = getpid(); -+ dfd = dirfd(topproc_dir); - while ((topproc_dent = readdir(topproc_dir)) != NULL) { -+ dev_t cwd_dev, exe_dev, root_dev; -+ struct stat *cwd_stat = NULL; -+ struct stat *exe_stat = NULL; -+ struct stat *root_stat = NULL; -+#ifdef _LISTS_H -+ char path[256] = "/proc/", *slash; -+ ssize_t len; -+#endif -+ - if (topproc_dent->d_name[0] < '0' || topproc_dent->d_name[0] > '9') /* Not a process */ - continue; - pid = atoi(topproc_dent->d_name); -@@ -169,57 +192,72 @@ scan_procs(struct names *names_head, str - continue; - uid = getpiduid(pid); - -- root_stat = get_pidstat(pid, "root"); -+#ifdef _LISTS_H -+ strcpy(&path[6], topproc_dent->d_name); -+ len = strlen(path); -+ slash = &path[len]; -+ -+ *slash = '\0'; -+ strcat(slash, "/cwd"); -+ cwd_dev = device(path); -+ -+ *slash = '\0'; -+ strcat(slash, "/exe"); -+ exe_dev = device(path); -+ -+ *slash = '\0'; -+ strcat(slash, "/root"); -+ root_dev = device(path); -+#else - cwd_stat = get_pidstat(pid, "cwd"); - exe_stat = get_pidstat(pid, "exe"); -+ root_stat = get_pidstat(pid, "root"); -+ cwd_dev = cwd_stat ? cwd_stat->st_dev : 0; -+ exe_dev = exe_stat ? exe_stat->st_dev : 0; -+ root_dev = root_stat ? root_stat->st_dev : 0; -+#endif -+ - /* Scan the devices */ -- for (dev_tmp = dev_head; dev_tmp != NULL; -- dev_tmp = dev_tmp->next) { -- if (exe_stat != NULL -- && exe_stat->st_dev == dev_tmp->device) -- add_matched_proc(dev_tmp->name, pid, uid, -- ACCESS_EXE); -- if (root_stat != NULL -- && root_stat->st_dev == dev_tmp->device) -- add_matched_proc(dev_tmp->name, pid, uid, -- ACCESS_ROOT); -- if (cwd_stat != NULL -- && cwd_stat->st_dev == dev_tmp->device) -- add_matched_proc(dev_tmp->name, pid, uid, -- ACCESS_CWD); -- } -- for (ino_tmp = ino_head; ino_tmp != NULL; -- ino_tmp = ino_tmp->next) { -- if (exe_stat != NULL) { -- if (exe_stat->st_dev == ino_tmp->device -- && exe_stat->st_ino == ino_tmp->inode) { -- add_matched_proc(ino_tmp->name, pid, -- uid, ACCESS_EXE); -- } -+ for (dev_tmp = dev_head; dev_tmp != NULL; dev_tmp = dev_tmp->next) { -+ if (exe_dev == dev_tmp->device) -+ add_matched_proc(dev_tmp->name, pid, uid, ACCESS_EXE); -+ if (root_dev == dev_tmp->device) -+ add_matched_proc(dev_tmp->name, pid, uid, ACCESS_ROOT); -+ if (cwd_dev == dev_tmp->device) -+ add_matched_proc(dev_tmp->name, pid, uid, ACCESS_CWD); -+ } -+ for (ino_tmp = ino_head; ino_tmp != NULL; ino_tmp = ino_tmp->next) { -+ if (exe_dev == ino_tmp->device) { -+ if (!exe_stat) -+ exe_stat = get_pidstat(pid, "exe"); -+ if (exe_stat && exe_stat->st_dev == ino_tmp->device -+ && exe_stat->st_ino == ino_tmp->inode) -+ add_matched_proc(ino_tmp->name, pid, uid, ACCESS_EXE); - } -- if (root_stat != NULL) { -- if (root_stat->st_dev == ino_tmp->device -- && root_stat->st_ino == ino_tmp->inode) { -- add_matched_proc(ino_tmp->name, pid, -- uid, ACCESS_ROOT); -- } -- -+ if (root_dev == ino_tmp->device) { -+ if (!root_stat) -+ root_stat = get_pidstat(pid, "root"); -+ if (root_stat && root_stat->st_dev == ino_tmp->device -+ && root_stat->st_ino == ino_tmp->inode) -+ add_matched_proc(ino_tmp->name, pid, uid, ACCESS_ROOT); - } -- if (cwd_stat != NULL) { -- if (cwd_stat->st_dev == ino_tmp->device -- && cwd_stat->st_ino == ino_tmp->inode) { -- add_matched_proc(ino_tmp->name, pid, -- uid, ACCESS_CWD); -- } -+ if (cwd_dev == ino_tmp->device) { -+ if (!cwd_stat) -+ cwd_stat = get_pidstat(pid, "cwd"); -+ if (cwd_stat && cwd_stat->st_dev == ino_tmp->device -+ && cwd_stat->st_ino == ino_tmp->inode) -+ add_matched_proc(ino_tmp->name, pid, uid, ACCESS_CWD); - } - } - if (root_stat) free(root_stat); - if (cwd_stat) free(cwd_stat); - if (exe_stat) free(exe_stat); -+#ifndef __linux__ - check_dir(pid, "lib", dev_head, ino_head, uid, ACCESS_MMAP, - sockets, netdev); - check_dir(pid, "mmap", dev_head, ino_head, uid, ACCESS_MMAP, - sockets, netdev); -+#endif - check_dir(pid, "fd", dev_head, ino_head, uid, ACCESS_FILE, - sockets, netdev); - check_map(pid, "maps", dev_head, ino_head, uid, ACCESS_MMAP); -@@ -392,9 +430,24 @@ add_special_proc(struct names *name_list - pptr->command = strdup(command); - } - --int parse_file(struct names *this_name, struct inode_list **ino_list) -+int parse_file(struct names *this_name, struct inode_list **ino_list, const char opts) - { -- if (stat(this_name->filename, &(this_name->st)) != 0) { -+ char * new = expandpath(this_name->filename); -+ if (new) { -+ if (this_name->filename) -+ free(this_name->filename); -+ this_name->filename = strdup(new); -+ } -+#ifdef _LISTS_H -+ if (opts & OPT_MOUNTS) { -+ this_name->st.st_dev = device(this_name->filename); -+ this_name->st.st_ino = 0; -+ add_inode(ino_list, this_name, this_name->st.st_dev, this_name->st.st_ino); -+ return 0; -+ } -+#endif -+ -+ if (timeout(stat, this_name->filename, &(this_name->st), 5) != 0) { - if (errno == ENOENT) - fprintf(stderr, _("Specified filename %s does not exist.\n"), this_name->filename); - else -@@ -1030,11 +1083,12 @@ int main(int argc, char *argv[]) - break; - default: /* FILE */ - this_name->filename = strdup(current_argv); -- if (parse_file(this_name, &match_inodes) == 0) { -- parse_unixsockets(this_name, &match_inodes, unixsockets); -+ if (parse_file(this_name, &match_inodes, opts) == 0) { - if (opts & OPT_MOUNTS) - parse_mounts(this_name, &match_devices, opts); -- } -+ else -+ parse_unixsockets(this_name, &match_inodes, unixsockets); -+ } - break; - } - -@@ -1258,7 +1312,7 @@ static struct stat *get_pidstat(const pi - if ((st = (struct stat*)malloc(sizeof(struct stat))) == NULL) - return NULL; - snprintf(pathname, 256, "/proc/%d/%s", pid, filename); -- if (stat(pathname, st) != 0) -+ if (timeout(stat, pathname, st, 5) != 0) - goto out; - return st; - out: -@@ -1278,6 +1332,7 @@ check_dir(const pid_t pid, const char *d - struct device_list *dev_tmp; - struct unixsocket_list *sock_tmp; - struct stat st, lst; -+ dev_t thedev; - - if ((dirpath = (char*)malloc(MAX_PATHNAME)) == NULL) - goto out; -@@ -1293,53 +1348,68 @@ check_dir(const pid_t pid, const char *d - - snprintf(filepath, MAX_PATHNAME, "/proc/%d/%s/%s", - pid, dirname, direntry->d_name); -- if (stat(filepath, &st) != 0) { -+ -+#ifdef _LISTS_H -+ st.st_ino = 0; -+ if ((thedev = device(filepath)) < 0) -+#else -+ if (!st.st_ino && timeout(stat, filepath, &st, 5) != 0) -+#endif -+ { - fprintf(stderr, _("Cannot stat file %s: %s\n"), - filepath, strerror(errno)); - } else { -- if (st.st_dev == netdev) { -+ if (thedev == netdev) { - for (sock_tmp = sockets; sock_tmp != NULL; - sock_tmp = sock_tmp->next) { - if (sock_tmp->net_inode == st.st_ino) { - st.st_ino = sock_tmp->inode; - st.st_dev = sock_tmp->dev; -+ thedev = sock_tmp->dev; - break; - } - } - } - for (dev_tmp = dev_head; dev_tmp != NULL; - dev_tmp = dev_tmp->next) { -- if (st.st_dev == dev_tmp->device) { -- if (access == ACCESS_FILE -- && (lstat(filepath, &lst) == 0) -- && (lst.st_mode & S_IWUSR)) { -- add_matched_proc(dev_tmp->name, -- pid, uid, -- ACCESS_FILEWR | -- access); -- } else { -- add_matched_proc(dev_tmp->name, -- pid, uid, -- access); -- } -+ if (thedev != dev_tmp->device) -+ continue; -+ if (access == ACCESS_FILE -+ && (lstat(filepath, &lst) == 0) -+ && (lst.st_mode & S_IWUSR)) { -+ add_matched_proc(dev_tmp->name, -+ pid, uid, -+ ACCESS_FILEWR | -+ access); -+ } else { -+ add_matched_proc(dev_tmp->name, -+ pid, uid, -+ access); - } - } - for (ino_tmp = ino_head; ino_tmp != NULL; - ino_tmp = ino_tmp->next) { -- if (st.st_dev == ino_tmp->device -- && st.st_ino == ino_tmp->inode) { -- if (access == ACCESS_FILE -- && (lstat(filepath, &lst) == 0) -- && (lst.st_mode & S_IWUSR)) { -- add_matched_proc(ino_tmp->name, -- pid, uid, -- ACCESS_FILEWR | -- access); -- } else { -- add_matched_proc(ino_tmp->name, -- pid, uid, -- access); -- } -+ if (thedev != ino_tmp->device) -+ continue; -+ if (!st.st_ino && timeout(stat, filepath, &st, 5) != 0) { -+ fprintf(stderr, -+ _("Cannot stat file %s: %s\n"), -+ filepath, strerror(errno)); -+ continue; -+ } -+ if (st.st_ino == ino_tmp->inode) { -+ if (access == ACCESS_FILE -+ && (lstat(filepath, &lst) == 0) -+ && (lst.st_mode & S_IWUSR)) { -+ add_matched_proc(ino_tmp->name, -+ pid, uid, -+ ACCESS_FILEWR | -+ access); -+ } else { -+ add_matched_proc(ino_tmp->name, -+ pid, uid, -+ access); -+ } - } - } - } -@@ -1396,7 +1466,7 @@ static uid_t getpiduid(const pid_t pid) - - if (snprintf(pathname, MAX_PATHNAME, "/proc/%d", pid) < 0) - return 0; -- if (stat(pathname, &st) != 0) -+ if (timeout(stat, pathname, &st, 5) != 0) - return 0; - return st.st_uid; - } -@@ -1432,7 +1502,7 @@ void fill_unix_cache(struct unixsocket_l - path = scanned_path; - if (*scanned_path == '@') - scanned_path++; -- if (stat(scanned_path, &st) < 0) { -+ if (timeout(stat, scanned_path, &st, 5) < 0) { - free(path); - continue; - } -@@ -1571,7 +1641,7 @@ scan_knfsd(struct names *names_head, str - if ((find_space = strpbrk(line, " \t")) == NULL) - continue; - *find_space = '\0'; -- if (stat(line, &st) != 0) { -+ if (timeout(stat, line, &st, 5) != 0) { - continue; - } - /* Scan the devices */ -@@ -1615,7 +1685,7 @@ scan_mounts(struct names *names_head, st - if ((find_space = strchr(find_mountp, ' ')) == NULL) - continue; - *find_space = '\0'; -- if (stat(find_mountp, &st) != 0) { -+ if (timeout(stat, find_mountp, &st, 5) != 0) { - continue; - } - /* Scan the devices */ -@@ -1662,7 +1732,7 @@ scan_swaps(struct names *names_head, str - if (*find_space == '\0') - continue; - } -- if (stat(line, &st) != 0) { -+ if (timeout(stat, line, &st, 5) != 0) { - continue; - } - /* Scan the devices */ -@@ -1682,3 +1752,281 @@ scan_swaps(struct names *names_head, str - } - fclose(fp); - } -+ -+/* -+ * Execute stat(2) system call with timeout to avoid deadlock -+ * on network based file systems. -+ */ -+static sigjmp_buf jenv; -+ -+static void -+sigalarm(int sig) -+{ -+ if (sig == SIGALRM) -+ siglongjmp(jenv, 1); -+} -+ -+static int -+timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds) -+{ -+ pid_t pid = 0; -+ int ret = 0, pipes[4]; -+ ssize_t len; -+ -+ if (pipe(&pipes[0]) < 0) -+ goto err; -+ switch ((pid = fork ())) { -+ case -1: -+ close(pipes[0]); -+ close(pipes[1]); -+ goto err; -+ case 0: -+ (void) signal(SIGALRM, SIG_DFL); -+ close(pipes[0]); -+ if ((ret = func(path, buf)) == 0) -+ do len = write(pipes[1], buf, sizeof(struct stat)); -+ while (len < 0 && errno == EINTR); -+ close(pipes[1]); -+ exit(ret); -+ default: -+ close(pipes[1]); -+ if (sigsetjmp(jenv, 1)) { -+ (void) alarm(0); -+ (void) signal(SIGALRM, SIG_DFL); -+ if (waitpid(0, (int*)0, WNOHANG) == 0) -+ kill(pid, SIGKILL); -+ errno = ETIMEDOUT; -+ seconds = 1; -+ goto err; -+ } -+ (void) signal(SIGALRM, sigalarm); -+ (void) alarm(seconds); -+ if (read(pipes[0], buf, sizeof(struct stat)) == 0) { -+ errno = EFAULT; -+ ret = -1; -+ } -+ (void) alarm(0); -+ (void) signal(SIGALRM, SIG_DFL); -+ close(pipes[0]); -+ break; -+ } -+ return ret; -+err: -+ return -1; -+} -+ -+#ifdef _LISTS_H -+/* -+ * Use /proc/self/mountinfo of modern linux system to determine -+ * the device numbers of the mount points. Use this to avoid the -+ * stat(2) system call wherever possible. -+ */ -+ -+static list_t mntinfo = {&mntinfo, &mntinfo}; -+ -+static void -+clear_mntinfo(void) -+{ -+ list_t *ptr, *tmp; -+ -+ list_for_each_safe(ptr, tmp, &mntinfo) { -+ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); -+ delete(ptr); -+ free(mnt); -+ } -+} -+ -+ -+static void -+init_mntinfo(void) -+{ -+ char mpoint[PATH_MAX+1]; -+ int mid, parid, max = 0; -+ uint maj, min; -+ list_t sort; -+ FILE * mnt; -+ -+ if (!list_empty(&mntinfo)) -+ return; -+ if ((mnt = fopen("/proc/self/mountinfo", "r")) == (FILE*)0) -+ return; -+ while (fscanf(mnt, "%i %i %u:%u %*s %s %*[^\n]", &mid, &parid, &maj, &min, &mpoint[0]) == 5) { -+ const size_t nlen = strlen(mpoint); -+ mntinfo_t *restrict mnt; -+ if (posix_memalign((void*)&mnt, sizeof(void*), alignof(mntinfo_t)+(nlen+1)) != 0) { -+ fprintf(stderr, _("Cannot allocate memory for matched proc: %s\n"), -+ strerror(errno)); -+ exit(1); -+ } -+ append(mnt, mntinfo); -+ mnt->mpoint = ((char*)mnt)+alignof(mntinfo_t); -+ strcpy(mnt->mpoint, mpoint); -+ mnt->nlen = nlen; -+ mnt->parid = parid; -+ mnt->dev = makedev(maj, min); -+ mnt->id = mid; -+ if (mid > max) -+ max = mid; -+ } -+ fclose(mnt); -+ -+ /* Sort mount points accordingly to the reverse mount order */ -+ initial(&sort); -+ for (mid = 1; mid <= max; mid++) { -+ list_t *ptr, *tmp; -+ list_for_each_safe(ptr, tmp, &mntinfo) { -+ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); -+ if (mid != mnt->id) -+ continue; -+ move_head(ptr, &sort); -+ break; -+ } -+ list_for_each_safe(ptr, tmp, &mntinfo) { -+ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); -+ if (mid != mnt->parid) -+ continue; -+ move_head(ptr, &sort); -+ } -+ } -+ if (!list_empty(&mntinfo)) { -+ errno = EBADE; -+ } -+ join(&sort, &mntinfo); -+} -+ -+/* -+ * Determine device of links below /proc/ -+ */ -+static dev_t -+device(const char * path) -+{ -+ char name[PATH_MAX+1]; -+ const char *use; -+ ssize_t nlen; -+ list_t *ptr; -+ -+ if ((nlen = readlink(path, name, PATH_MAX)) < 0) { -+ nlen = strlen(path); -+ use = &path[0]; -+ } else { -+ name[nlen] = '\0'; -+ use = &name[0]; -+ } -+ -+ if (*use != '/') { /* special file (socket, pipe, inotify) */ -+ struct stat st; -+ if (timeout(stat, path, &st, 5) != 0) -+ return (dev_t)-1; -+ return st.st_dev; -+ } -+ -+ list_for_each(ptr, &mntinfo) { -+ mntinfo_t *mnt = list_entry(ptr, mntinfo_t); -+ if (nlen < mnt->nlen) -+ continue; -+ if (mnt->nlen == 1) /* root fs is the last entry */ -+ return mnt->dev; -+ if (use[mnt->nlen] != '\0' && use[mnt->nlen] != '/') -+ continue; -+ if (strncmp(use, mnt->mpoint, mnt->nlen) == 0) -+ return mnt->dev; -+ } -+ return (dev_t)-1; -+} -+#endif /* _LISTS_H */ -+ -+/* -+ * Somehow the realpath(3) glibc function call, nevertheless -+ * it avoids lstat(2) system calls. -+ */ -+static char real[PATH_MAX+1]; -+char* expandpath(const char * path) -+{ -+ char tmpbuf[PATH_MAX+1]; -+ const char *start, *end; -+ char *curr, *dest; -+ int deep = MAXSYMLINKS; -+ -+ if (!path || *path == '\0') -+ return (char*)0; -+ -+ curr = &real[0]; -+ -+ if (*path != '/') { -+ if (!getcwd(curr, PATH_MAX)) -+ return (char*)0; -+ dest = rawmemchr(curr, '\0'); -+ } else { -+ *curr = '/'; -+ dest = curr + 1; -+ } -+ -+ for (start = end = path; *start; start = end) { -+ -+ while (*start == '/') -+ ++start; -+ -+ for (end = start; *end && *end != '/'; ++end) -+ ; -+ -+ if (end - start == 0) -+ break; -+ else if (end - start == 1 && start[0] == '.') { -+ ; -+ } else if (end - start == 2 && start[0] == '.' && start[1] == '.') { -+ if (dest > curr + 1) -+ while ((--dest)[-1] != '/') -+ ; -+ } else { -+ char lnkbuf[PATH_MAX+1]; -+ size_t len; -+ ssize_t n; -+ -+ if (dest[-1] != '/') -+ *dest++ = '/'; -+ -+ if (dest + (end - start) > curr + PATH_MAX) { -+ errno = ENAMETOOLONG; -+ return (char*)0; -+ } -+ -+ dest = mempcpy(dest, start, end - start); -+ *dest = '\0'; -+ -+ if (deep-- < 0) { -+ errno = ELOOP; -+ return (char*)0; -+ } -+ -+ errno = 0; -+ if ((n = readlink(curr, lnkbuf, PATH_MAX)) < 0) { -+ deep = MAXSYMLINKS; -+ if (errno == EINVAL) -+ continue; /* Not a symlink */ -+ return (char*)0; -+ } -+ lnkbuf[n] = '\0'; /* Don't be fooled by readlink(2) */ -+ -+ len = strlen(end); -+ if ((n + len) > PATH_MAX) { -+ errno = ENAMETOOLONG; -+ return (char*)0; -+ } -+ -+ memmove(&tmpbuf[n], end, len + 1); -+ path = end = memcpy(tmpbuf, lnkbuf, n); -+ -+ if (lnkbuf[0] == '/') -+ dest = curr + 1; -+ else if (dest > curr + 1) -+ while ((--dest)[-1] != '/'); -+ -+ } -+ } -+ -+ if (dest > curr + 1 && dest[-1] == '/') -+ --dest; -+ *dest = '\0'; -+ -+ return curr; -+} ---- src/fuser.h -+++ src/fuser.h 2011-02-09 09:38:34.764426085 +0000 -@@ -85,6 +85,17 @@ struct mount_list { - struct mount_list *next; - }; - -+#if defined (__GNUC__) && defined(__OPTIMIZE__) -+# include "lists.h" -+typedef struct mntinfo_s { -+ list_t this; -+ int id, parid; -+ dev_t dev; -+ size_t nlen; -+ char *mpoint; -+} mntinfo_t; -+#endif -+ - #define NAMESPACE_FILE 0 - #define NAMESPACE_TCP 1 - #define NAMESPACE_UDP 2 ---- src/lists.h -+++ src/lists.h 2011-02-07 12:01:52.000000000 +0000 -@@ -0,0 +1,249 @@ -+/* -+ * lists.h Simple doubly linked list implementation, -+ * based on and . -+ * -+ * Version: 0.1 01-Feb-2011 Fink -+ * -+ * Copyright 2011 Werner Fink, 2005 SUSE LINUX Products GmbH, Germany. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * Author: Werner Fink , 2011 -+ */ -+ -+#ifndef _LISTS_H -+#define _LISTS_H -+ -+#include -+#include -+ -+typedef enum _boolean {false, true} boolean; -+typedef unsigned char uchar; -+#ifndef __USE_MISC -+typedef unsigned short ushort; -+typedef unsigned int uint; -+#endif -+ -+#ifndef __OPTIMIZE__ -+# warning This will not compile without -O at least -+#endif -+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) -+# ifndef inline -+# define inline __inline__ -+# endif -+# ifndef restrict -+# define restrict __restrict__ -+# endif -+# ifndef volatile -+# define volatile __volatile__ -+# endif -+# ifndef asm -+# define asm __asm__ -+# endif -+# ifndef extension -+# define extension __extension__ -+# endif -+#endif -+#ifndef attribute -+# define attribute(attr) __attribute__(attr) -+#endif -+ -+/* -+ * This is lent from the kernel by e.g. using -+ * -+ * echo '#include \nint main () { prefetch(); return 0; }' | \ -+ * gcc -I/usr/src/linux/include -D__KERNEL__ -x c -E -P - | \ -+ * sed -rn '/void[[:blank:]]+prefetch[[:blank:]]*\(/,/^}/p' -+ * -+ * on the appropiate architecture (here on i686 for i586). -+ */ -+extern inline void attribute((used,__gnu_inline__,always_inline,__artificial__)) prefetch(const void *restrict x) -+{ -+#if defined(__x86_64__) -+ asm volatile ("prefetcht0 %0" :: "m" (*(unsigned long *)x)) -+#elif defined(__ia64__) -+ asm volatile ("lfetch [%0]" :: "r" (x)) -+#elif defined(__powerpc64__) -+ asm volatile ("dcbt 0,%0" :: "r" (x)) -+#elif 1 && defined(__i386__) -+ asm volatile ("661:\n\t" -+ ".byte 0x8d,0x74,0x26,0x00\n" -+ "\n662:\n" -+ ".section .altinstructions,\"a\"\n" -+ " .align 4\n" -+ " .long 661b\n" -+ " .long 663f\n" -+ " .byte %c0\n" -+ " .byte 662b-661b\n" -+ " .byte 664f-663f\n" -+ ".previous\n" -+ ".section .altinstr_replacement,\"ax\"\n" -+ " 663:\n\t" -+ " prefetchnta (%1)" -+ " \n664:\n" -+ ".previous" -+ :: "i" ((0*32+25)), "r" (x)) -+#else -+ __builtin_prefetch ((x), 0, 1); -+#endif -+ ; -+} -+ -+#if defined(DEBUG) && (DEBUG > 0) -+# define __align attribute((packed)) -+#else -+# define __align attribute((aligned(sizeof(struct list_struct*)))) -+#endif -+#define __packed attribute((packed)) -+ -+#define alignof(type) ((sizeof(type)+(sizeof(void*)-1)) & ~(sizeof(void*)-1)) -+#define strsize(string) ((strlen(string)+1)*sizeof(char)) -+ -+typedef struct list_struct { -+ struct list_struct * next, * prev; -+} __align list_t; -+ -+/* -+ * Linked list handling -+ * ==================== -+ * The structures which will be linked into such lists have to be of the -+ * same type. The structures may have alway a list identifier of the type -+ * `list_t' as very first element. With this the macro list_entry() can -+ * be used to cast the memory address of a list member to the corresponding -+ * allocated structure. -+ */ -+ -+/* -+ * Insert new entry as next member. -+ */ -+static inline void _insert(list_t *restrict new, list_t *restrict here) attribute((always_inline,nonnull(1,2))); -+static inline void _insert(list_t *restrict new, list_t *restrict here) -+{ -+ list_t * prev = here; -+ list_t * next = here->next; -+ -+ next->prev = new; -+ new->next = next; -+ new->prev = prev; -+ prev->next = new; -+} -+ -+#define insert(new, list) _insert(&((new)->this), (&(list))); -+#define append(new, list) _insert(&((new)->this), (&(list))->prev); -+ -+/* -+ * Set head -+ */ -+static inline void initial(list_t *restrict head) attribute((always_inline,nonnull(1))); -+static inline void initial(list_t *restrict head) -+{ -+ head->prev = head->next = head; -+} -+ -+/* -+ * Remove entries, note that the pointer its self remains. -+ */ -+static inline void delete(list_t *restrict entry) attribute((always_inline,nonnull(1))); -+static inline void delete(list_t *restrict entry) -+{ -+ list_t * prev = entry->prev; -+ list_t * next = entry->next; -+ -+ next->prev = prev; -+ prev->next = next; -+ -+ initial(entry); -+} -+ -+/* -+ * Replace an entry by a new one. -+ */ -+static inline void replace(list_t *restrict old, list_t *restrict new) attribute((always_inline,nonnull(1,2))); -+static inline void replace(list_t *restrict old, list_t *restrict new) -+{ -+ new->next = old->next; -+ new->next->prev = new; -+ new->prev = old->prev; -+ new->prev->next = new; -+} -+ -+static inline void join(list_t *restrict list, list_t *restrict head) attribute((always_inline,nonnull(1,2))); -+static inline void join(list_t *restrict list, list_t *restrict head) -+{ -+ list_t * first = list->next; -+ -+ if (first != list) { -+ list_t * last = list->prev; -+ list_t * at = head->next; -+ -+ first->prev = head; -+ head->next = first; -+ -+ last->next = at; -+ at->prev = last; -+ } -+} -+ -+static inline boolean list_empty(const list_t *restrict const head) attribute((always_inline,nonnull(1))); -+static inline boolean list_empty(const list_t *restrict const head) -+{ -+ return head->next == head; -+} -+ -+static inline void move_head(list_t *restrict entry, list_t *restrict head) attribute((always_inline,nonnull(1,2))); -+static inline void move_head(list_t *restrict entry, list_t *restrict head) -+{ -+ list_t * prev = entry->prev; -+ list_t * next = entry->next; -+ -+ next->prev = prev; /* remove entry from old list */ -+ prev->next = next; -+ -+ prev = head; -+ next = head->next; -+ -+ next->prev = entry; /* and add it at head of new list */ -+ entry->next = next; -+ entry->prev = prev; -+ prev->next = entry; -+} -+ -+static inline void move_tail(list_t *restrict entry, list_t *restrict head) attribute((always_inline,nonnull(1,2))); -+static inline void move_tail(list_t *restrict entry, list_t *restrict head) -+{ -+ list_t * prev = entry->prev; -+ list_t * next = entry->next; -+ -+ next->prev = prev; /* remove entry from old list */ -+ prev->next = next; -+ -+ prev = head->prev; -+ next = head; -+ -+ next->prev = entry; /* and add it at tail of new list */ -+ entry->next = next; -+ entry->prev = prev; -+ prev->next = entry; -+} -+ -+/* -+ * The handle of the list is named `this' -+ */ -+#define list_entry(ptr, type) (__extension__ ({ \ -+ const typeof( ((type *)0)->this ) *__mptr = (ptr); \ -+ ((type *)( (char *)(__mptr) - offsetof(type,this) )); })) -+#define list_for_each(pos, head) \ -+ for (pos = (head)->next; prefetch(pos->next), pos != (head); pos = pos->next) -+#define np_list_for_each(pos, head) \ -+ for (pos = (head)->next; pos != (head); pos = pos->next) -+#define list_for_each_safe(pos, safe, head) \ -+ for (pos = (head)->next, safe = pos->next; pos != (head); pos = safe, safe = pos->next) -+#define list_for_each_prev(pos, head) \ -+ for (pos = (head)->prev; prefetch(pos->prev), pos != (head); pos = pos->prev) -+#define np_list_for_each_prev(pos, head) \ -+ for (pos = (head)->prev; pos != (head); pos = pos->prev) -+ -+#endif /* _LISTS_H */ diff --git a/psmisc-22.13-peekfd-segv.patch b/psmisc-22.13-peekfd-segv.patch deleted file mode 100644 index 8e7049d..0000000 --- a/psmisc-22.13-peekfd-segv.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/peekfd.c b/src/peekfd.c -index 2c30f25..6d759b9 100644 ---- a/src/peekfd.c -+++ b/src/peekfd.c -@@ -199,7 +199,7 @@ int main(int argc, char **argv) - numfds = argc - optind; - fds = malloc(sizeof(int) * numfds); - for (i = 0; i < numfds; i++) -- fds[i] = atoi(argv[optind + i + 1]); -+ fds[i] = atoi(argv[optind + i]); - } - - attach(target_pid); diff --git a/psmisc-22.13.tar.bz2 b/psmisc-22.13.tar.bz2 deleted file mode 100644 index c4d41a9..0000000 --- a/psmisc-22.13.tar.bz2 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:45531c27bae46be5168a98edcbfc5f68c811176261631249880bc454e551c712 -size 303260 diff --git a/psmisc-22.14-toomuch.dif b/psmisc-22.14-toomuch.dif new file mode 100644 index 0000000..a8af6f8 --- /dev/null +++ b/psmisc-22.14-toomuch.dif @@ -0,0 +1,255 @@ +--- src/lists.h ++++ src/lists.h 2011-06-21 13:38:35.696426015 +0000 +@@ -247,252 +247,3 @@ static inline void move_tail(list_t *res + for (pos = (head)->prev; pos != (head); pos = pos->prev) + + #endif /* _LISTS_H */ +-/* +- * lists.h Simple doubly linked list implementation, +- * based on and . +- * +- * Version: 0.1 01-Feb-2011 Fink +- * +- * Copyright 2011 Werner Fink, 2005 SUSE LINUX Products GmbH, Germany. +- * +- * This program is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published by +- * the Free Software Foundation; either version 2 of the License, or +- * (at your option) any later version. +- * +- * Author: Werner Fink , 2011 +- */ +- +-#ifndef _LISTS_H +-#define _LISTS_H +- +-#include +-#include +- +-typedef enum _boolean {false, true} boolean; +-typedef unsigned char uchar; +-#ifndef __USE_MISC +-typedef unsigned short ushort; +-typedef unsigned int uint; +-#endif +- +-#ifndef __OPTIMIZE__ +-# warning This will not compile without -O at least +-#endif +-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) +-# ifndef inline +-# define inline __inline__ +-# endif +-# ifndef restrict +-# define restrict __restrict__ +-# endif +-# ifndef volatile +-# define volatile __volatile__ +-# endif +-# ifndef asm +-# define asm __asm__ +-# endif +-# ifndef extension +-# define extension __extension__ +-# endif +-#endif +-#ifndef attribute +-# define attribute(attr) __attribute__(attr) +-#endif +- +-/* +- * This is lent from the kernel by e.g. using +- * +- * echo '#include \nint main () { prefetch(); return 0; }' | \ +- * gcc -I/usr/src/linux/include -D__KERNEL__ -x c -E -P - | \ +- * sed -rn '/void[[:blank:]]+prefetch[[:blank:]]*\(/,/^}/p' +- * +- * on the appropiate architecture (here on i686 for i586). +- */ +-extern inline void attribute((used,__gnu_inline__,always_inline,__artificial__)) prefetch(const void *restrict x) +-{ +-#if defined(__x86_64__) +- asm volatile ("prefetcht0 %0" :: "m" (*(unsigned long *)x)) +-#elif defined(__ia64__) +- asm volatile ("lfetch [%0]" :: "r" (x)) +-#elif defined(__powerpc64__) +- asm volatile ("dcbt 0,%0" :: "r" (x)) +-#elif 1 && defined(__i386__) +- asm volatile ("661:\n\t" +- ".byte 0x8d,0x74,0x26,0x00\n" +- "\n662:\n" +- ".section .altinstructions,\"a\"\n" +- " .align 4\n" +- " .long 661b\n" +- " .long 663f\n" +- " .byte %c0\n" +- " .byte 662b-661b\n" +- " .byte 664f-663f\n" +- ".previous\n" +- ".section .altinstr_replacement,\"ax\"\n" +- " 663:\n\t" +- " prefetchnta (%1)" +- " \n664:\n" +- ".previous" +- :: "i" ((0*32+25)), "r" (x)) +-#else +- __builtin_prefetch ((x), 0, 1); +-#endif +- ; +-} +- +-#if defined(DEBUG) && (DEBUG > 0) +-# define __align attribute((packed)) +-#else +-# define __align attribute((aligned(sizeof(struct list_struct*)))) +-#endif +-#define __packed attribute((packed)) +- +-#define alignof(type) ((sizeof(type)+(sizeof(void*)-1)) & ~(sizeof(void*)-1)) +-#define strsize(string) ((strlen(string)+1)*sizeof(char)) +- +-typedef struct list_struct { +- struct list_struct * next, * prev; +-} __align list_t; +- +-/* +- * Linked list handling +- * ==================== +- * The structures which will be linked into such lists have to be of the +- * same type. The structures may have alway a list identifier of the type +- * `list_t' as very first element. With this the macro list_entry() can +- * be used to cast the memory address of a list member to the corresponding +- * allocated structure. +- */ +- +-/* +- * Insert new entry as next member. +- */ +-static inline void _insert(list_t *restrict new, list_t *restrict here) attribute((always_inline,nonnull(1,2))); +-static inline void _insert(list_t *restrict new, list_t *restrict here) +-{ +- list_t * prev = here; +- list_t * next = here->next; +- +- next->prev = new; +- new->next = next; +- new->prev = prev; +- prev->next = new; +-} +- +-#define insert(new, list) _insert(&((new)->this), (&(list))); +-#define append(new, list) _insert(&((new)->this), (&(list))->prev); +- +-/* +- * Set head +- */ +-static inline void initial(list_t *restrict head) attribute((always_inline,nonnull(1))); +-static inline void initial(list_t *restrict head) +-{ +- head->prev = head->next = head; +-} +- +-/* +- * Remove entries, note that the pointer its self remains. +- */ +-static inline void delete(list_t *restrict entry) attribute((always_inline,nonnull(1))); +-static inline void delete(list_t *restrict entry) +-{ +- list_t * prev = entry->prev; +- list_t * next = entry->next; +- +- next->prev = prev; +- prev->next = next; +- +- initial(entry); +-} +- +-/* +- * Replace an entry by a new one. +- */ +-static inline void replace(list_t *restrict old, list_t *restrict new) attribute((always_inline,nonnull(1,2))); +-static inline void replace(list_t *restrict old, list_t *restrict new) +-{ +- new->next = old->next; +- new->next->prev = new; +- new->prev = old->prev; +- new->prev->next = new; +-} +- +-static inline void join(list_t *restrict list, list_t *restrict head) attribute((always_inline,nonnull(1,2))); +-static inline void join(list_t *restrict list, list_t *restrict head) +-{ +- list_t * first = list->next; +- +- if (first != list) { +- list_t * last = list->prev; +- list_t * at = head->next; +- +- first->prev = head; +- head->next = first; +- +- last->next = at; +- at->prev = last; +- } +-} +- +-static inline boolean list_empty(const list_t *restrict const head) attribute((always_inline,nonnull(1))); +-static inline boolean list_empty(const list_t *restrict const head) +-{ +- return head->next == head; +-} +- +-static inline void move_head(list_t *restrict entry, list_t *restrict head) attribute((always_inline,nonnull(1,2))); +-static inline void move_head(list_t *restrict entry, list_t *restrict head) +-{ +- list_t * prev = entry->prev; +- list_t * next = entry->next; +- +- next->prev = prev; /* remove entry from old list */ +- prev->next = next; +- +- prev = head; +- next = head->next; +- +- next->prev = entry; /* and add it at head of new list */ +- entry->next = next; +- entry->prev = prev; +- prev->next = entry; +-} +- +-static inline void move_tail(list_t *restrict entry, list_t *restrict head) attribute((always_inline,nonnull(1,2))); +-static inline void move_tail(list_t *restrict entry, list_t *restrict head) +-{ +- list_t * prev = entry->prev; +- list_t * next = entry->next; +- +- next->prev = prev; /* remove entry from old list */ +- prev->next = next; +- +- prev = head->prev; +- next = head; +- +- next->prev = entry; /* and add it at tail of new list */ +- entry->next = next; +- entry->prev = prev; +- prev->next = entry; +-} +- +-/* +- * The handle of the list is named `this' +- */ +-#define list_entry(ptr, type) (__extension__ ({ \ +- const typeof( ((type *)0)->this ) *__mptr = (ptr); \ +- ((type *)( (char *)(__mptr) - offsetof(type,this) )); })) +-#define list_for_each(pos, head) \ +- for (pos = (head)->next; prefetch(pos->next), pos != (head); pos = pos->next) +-#define np_list_for_each(pos, head) \ +- for (pos = (head)->next; pos != (head); pos = pos->next) +-#define list_for_each_safe(pos, safe, head) \ +- for (pos = (head)->next, safe = pos->next; pos != (head); pos = safe, safe = pos->next) +-#define list_for_each_prev(pos, head) \ +- for (pos = (head)->prev; prefetch(pos->prev), pos != (head); pos = pos->prev) +-#define np_list_for_each_prev(pos, head) \ +- for (pos = (head)->prev; pos != (head); pos = pos->prev) +- +-#endif /* _LISTS_H */ diff --git a/psmisc-22.13.dif b/psmisc-22.14.dif similarity index 100% rename from psmisc-22.13.dif rename to psmisc-22.14.dif diff --git a/psmisc-22.14.tar.gz b/psmisc-22.14.tar.gz new file mode 100644 index 0000000..c8458d9 --- /dev/null +++ b/psmisc-22.14.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42c30ad9a9a85429edd0e84763e1333a1d0711d90e4f1943ecb1211d6f98ee42 +size 382041 diff --git a/psmisc.changes b/psmisc.changes index 834d7f9..0996957 100644 --- a/psmisc.changes +++ b/psmisc.changes @@ -1,3 +1,27 @@ +------------------------------------------------------------------- +Tue Jun 21 15:56:45 CEST 2011 - werner@suse.de + +- Update to version 22.14: + + Fix file descriptor as weel as memory leaks in fuser + + Strip @ symbol from file names read from /proc/net/unix + + Above 2 changes close openSuSE bugs #536209, #529520, and #417841 + and provided by Werner Fink + + Applied patch from Werner Fink to avoid stat(2) on NFS mounts + + Zeros process group memory - Patch by jgorig SF#3152925 RH#666213 + + fuser -m -s flags work - Patch by jgorig SF#31110178 RH#651794 + + fuser silent if /proc/swaps not available SF#3072134 + + ppc 64 support for peekfd by jgorig SF#3166444 + + jiffies now ULL in killall SF#3138538 + + pstree can show parents of a process. Patch supplied by Curtis + Hawthorne SF#3135157 + + killall creates right size buffer instead of MAX_PATH Debian #623425 + + check for /proc/$$/stat not /proc/self/stat which is not available + on hurd platforms. Same Debian bug as above + + fuser understands IPv6 addresses, removed comment in fuser.1 that it + doesn't Debian #609904 + + fuser -k only returns 0 if you kill something. + + fuser doesn't complain if /proc/#/fd disappears SF#3310990 + ------------------------------------------------------------------- Tue Feb 8 17:43:57 CET 2011 - werner@suse.de diff --git a/psmisc.spec b/psmisc.spec index c37481f..e4a73dc 100644 --- a/psmisc.spec +++ b/psmisc.spec @@ -1,7 +1,7 @@ # -# spec file for package psmisc (Version 22.13) +# spec file for package psmisc # -# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -21,23 +21,20 @@ Name: psmisc BuildRequires: gcc-c++ glibc-devel ncurses-devel BuildRequires: libselinux-devel -Url: http://switch.dl.sourceforge.net/sourceforge/psmisc/ +Url: http://sourceforge.net/projects/psmisc/ License: GPLv2+ Group: System/Monitoring PreReq: %fillup_prereq %insserv_prereq -Version: 22.13 -Release: 2 +Version: 22.14 +Release: 1 Provides: ps:/usr/bin/killall Summary: Utilities for managing processes on your system -Source: http://switch.dl.sourceforge.net/sourceforge/psmisc/%{name}-%{version}.tar.bz2 -Patch0: %name-22.13.dif +Source: http://sourceforge.net/projects/psmisc/files/psmisc/%{name}-%{version}.tar.gz +Patch0: %name-22.14.dif Patch1: %name-22.12-tigetstr.patch Patch2: %name-22.12-pstree_overflow.patch Patch3: %name-22.12-pstree.patch -Patch4: %name-22.12-leaks.patch -Patch5: %name-22.13-nfs4fuser.patch -Patch6: %name-22.12-writeonly.patch -Patch7: %name-22.13-peekfd-segv.patch +Patch4: %name-22.14-toomuch.dif BuildRoot: %{_tmppath}/%{name}-%{version}-build %define nopeek s390 s390x ia64 %sparc hppa @@ -55,10 +52,7 @@ processes that are using specified files or filesystems. %patch1 -p0 -b .tigetstr %patch2 -p0 -b .pstreeovfl %patch3 -p0 -b .pstree -%patch4 -p0 -b .leaks -%patch5 -p0 -b .nfs4fuser -%patch6 -p0 -b .wrtonly -%patch7 -p1 -b .peekfd +%patch4 -p0 -b .2much %patch0 -p0 -b .0 %build From a32275260619956d036be4c6e38546bef6a7d6f017e09f7ff5cc647f7f4ca132 Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Tue, 28 Jun 2011 08:29:39 +0000 Subject: [PATCH 2/4] Accepting request 74716 from Base:System baserev update by copy to link target OBS-URL: https://build.opensuse.org/request/show/74716 OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=37 --- .gitattributes | 2 - _service:download_files:psmisc-22.14.tar.gz | 3 - _service:download_files:psmisc-22.14.tar.gz.1 | 3 - _service:format_spec_file:psmisc.spec | 105 ------------------ 4 files changed, 113 deletions(-) delete mode 100644 _service:download_files:psmisc-22.14.tar.gz delete mode 100644 _service:download_files:psmisc-22.14.tar.gz.1 delete mode 100644 _service:format_spec_file:psmisc.spec diff --git a/.gitattributes b/.gitattributes index 3997efa..9b03811 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,5 +21,3 @@ *.xz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text -## Specific LFS patterns -_service:download_files:psmisc-22.14.tar.gz.1 filter=lfs diff=lfs merge=lfs -text diff --git a/_service:download_files:psmisc-22.14.tar.gz b/_service:download_files:psmisc-22.14.tar.gz deleted file mode 100644 index 4571830..0000000 --- a/_service:download_files:psmisc-22.14.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:22bbf4561837af475c0d8d14e3b9cab453998c787212c107fac7faf2f281e26e -size 382024 diff --git a/_service:download_files:psmisc-22.14.tar.gz.1 b/_service:download_files:psmisc-22.14.tar.gz.1 deleted file mode 100644 index 4571830..0000000 --- a/_service:download_files:psmisc-22.14.tar.gz.1 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:22bbf4561837af475c0d8d14e3b9cab453998c787212c107fac7faf2f281e26e -size 382024 diff --git a/_service:format_spec_file:psmisc.spec b/_service:format_spec_file:psmisc.spec deleted file mode 100644 index 29c2ebb..0000000 --- a/_service:format_spec_file:psmisc.spec +++ /dev/null @@ -1,105 +0,0 @@ -# -# spec file for package psmisc -# -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. -# -# All modifications and additions to the file contributed by third parties -# remain the property of their copyright owners, unless otherwise agreed -# upon. The license for this file, and modifications and additions to the -# file, is the same license as for the pristine package itself (unless the -# license for the pristine package is not an Open Source License, in which -# case the license is the MIT License). An "Open Source License" is a -# license that conforms to the Open Source Definition (Version 1.9) -# published by the Open Source Initiative. - -# Please submit bugfixes or comments via http://bugs.opensuse.org/ -# - -# norootforbuild - - -Name: psmisc -BuildRequires: gcc-c++ glibc-devel ncurses-devel -BuildRequires: libselinux-devel -Url: http://sourceforge.net/projects/psmisc/ -License: GPLv2+ -Group: System/Monitoring -PreReq: %fillup_prereq %insserv_prereq -Version: 22.14 -Release: 1 -Provides: ps:/usr/bin/killall -Summary: Utilities for managing processes on your system -Source: http://sourceforge.net/projects/psmisc/files/psmisc/%{name}-%{version}.tar.gz -Patch0: %name-22.14.dif -Patch1: %name-22.12-tigetstr.patch -Patch2: %name-22.12-pstree_overflow.patch -Patch3: %name-22.12-pstree.patch -Patch4: %name-22.14-toomuch.dif - -BuildRoot: %{_tmppath}/%{name}-%{version}-build -%define nopeek s390 s390x ia64 %sparc hppa - - -%description -The psmisc package contains utilities for managing processes on your -system: pstree, killall and fuser. The pstree command displays a tree -structure of all of the running processes on your system. The killall -command sends a specified signal (SIGTERM if nothing is specified) to -processes identified by name. The fuser command identifies the PIDs of -processes that are using specified files or filesystems. - -%prep -%setup -q -%patch1 -p0 -b .tigetstr -%patch2 -p0 -b .pstreeovfl -%patch3 -p0 -b .pstree -%patch4 -p0 -b .2much -%patch0 -p0 -b .0 - - -%build -autoreconf -fi -CFLAGS="-D_GNU_SOURCE ${RPM_OPT_FLAGS} -pipe" -CXXFLAGS="$CFLAGS" -CC=gcc -CXX=g++ -export CFLAGS CXXFLAGS CC CXX -sh ./configure --prefix=%{_prefix} --mandir=%{_mandir} --enable-selinux -make %{?_smp_mflags} CFLAGS="$CFLAGS" "CC=$CC" - - -%install -make DESTDIR=$RPM_BUILD_ROOT install -mkdir -p $RPM_BUILD_ROOT/bin/ -mv $RPM_BUILD_ROOT/usr/bin/fuser $RPM_BUILD_ROOT/bin/ -%ifarch %nopeek -rm -f $RPM_BUILD_ROOT%{_mandir}/man1/peekfd.1* -%endif -%find_lang psmisc - - -%clean -rm -rf $RPM_BUILD_ROOT - - -%files -f psmisc.lang -%defattr (-,root,root,755) -/bin/fuser -%{_bindir}/killall -%ifnarch %nopeek -%{_bindir}/peekfd -%endif -%{_bindir}/prtstat -%{_bindir}/pstree -%{_bindir}/pstree.x11 -%{_mandir}/man1/fuser.1* -%{_mandir}/man1/killall.1* -%ifnarch %nopeek -%{_mandir}/man1/peekfd.1* -%endif -%{_mandir}/man1/prtstat.1* -%{_mandir}/man1/pstree.1* - - - -%changelog From 7b9794ef1a87aa5eb6bc9626d4698187d1e877604e411b7968b49f03dd27ad83 Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Tue, 28 Jun 2011 08:29:55 +0000 Subject: [PATCH 3/4] Updating link to change in openSUSE:Factory/psmisc revision 37.0 OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=7e4bfdb8d3ef0ef384974bf129103522 --- .gitattributes | 2 + _service:download_files:psmisc-22.14.tar.gz | 3 + _service:download_files:psmisc-22.14.tar.gz.1 | 3 + _service:format_spec_file:psmisc.spec | 105 ++++++++++++++++++ 4 files changed, 113 insertions(+) create mode 100644 _service:download_files:psmisc-22.14.tar.gz create mode 100644 _service:download_files:psmisc-22.14.tar.gz.1 create mode 100644 _service:format_spec_file:psmisc.spec diff --git a/.gitattributes b/.gitattributes index 9b03811..3997efa 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,3 +21,5 @@ *.xz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text +## Specific LFS patterns +_service:download_files:psmisc-22.14.tar.gz.1 filter=lfs diff=lfs merge=lfs -text diff --git a/_service:download_files:psmisc-22.14.tar.gz b/_service:download_files:psmisc-22.14.tar.gz new file mode 100644 index 0000000..4571830 --- /dev/null +++ b/_service:download_files:psmisc-22.14.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22bbf4561837af475c0d8d14e3b9cab453998c787212c107fac7faf2f281e26e +size 382024 diff --git a/_service:download_files:psmisc-22.14.tar.gz.1 b/_service:download_files:psmisc-22.14.tar.gz.1 new file mode 100644 index 0000000..4571830 --- /dev/null +++ b/_service:download_files:psmisc-22.14.tar.gz.1 @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:22bbf4561837af475c0d8d14e3b9cab453998c787212c107fac7faf2f281e26e +size 382024 diff --git a/_service:format_spec_file:psmisc.spec b/_service:format_spec_file:psmisc.spec new file mode 100644 index 0000000..29c2ebb --- /dev/null +++ b/_service:format_spec_file:psmisc.spec @@ -0,0 +1,105 @@ +# +# spec file for package psmisc +# +# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# + +# norootforbuild + + +Name: psmisc +BuildRequires: gcc-c++ glibc-devel ncurses-devel +BuildRequires: libselinux-devel +Url: http://sourceforge.net/projects/psmisc/ +License: GPLv2+ +Group: System/Monitoring +PreReq: %fillup_prereq %insserv_prereq +Version: 22.14 +Release: 1 +Provides: ps:/usr/bin/killall +Summary: Utilities for managing processes on your system +Source: http://sourceforge.net/projects/psmisc/files/psmisc/%{name}-%{version}.tar.gz +Patch0: %name-22.14.dif +Patch1: %name-22.12-tigetstr.patch +Patch2: %name-22.12-pstree_overflow.patch +Patch3: %name-22.12-pstree.patch +Patch4: %name-22.14-toomuch.dif + +BuildRoot: %{_tmppath}/%{name}-%{version}-build +%define nopeek s390 s390x ia64 %sparc hppa + + +%description +The psmisc package contains utilities for managing processes on your +system: pstree, killall and fuser. The pstree command displays a tree +structure of all of the running processes on your system. The killall +command sends a specified signal (SIGTERM if nothing is specified) to +processes identified by name. The fuser command identifies the PIDs of +processes that are using specified files or filesystems. + +%prep +%setup -q +%patch1 -p0 -b .tigetstr +%patch2 -p0 -b .pstreeovfl +%patch3 -p0 -b .pstree +%patch4 -p0 -b .2much +%patch0 -p0 -b .0 + + +%build +autoreconf -fi +CFLAGS="-D_GNU_SOURCE ${RPM_OPT_FLAGS} -pipe" +CXXFLAGS="$CFLAGS" +CC=gcc +CXX=g++ +export CFLAGS CXXFLAGS CC CXX +sh ./configure --prefix=%{_prefix} --mandir=%{_mandir} --enable-selinux +make %{?_smp_mflags} CFLAGS="$CFLAGS" "CC=$CC" + + +%install +make DESTDIR=$RPM_BUILD_ROOT install +mkdir -p $RPM_BUILD_ROOT/bin/ +mv $RPM_BUILD_ROOT/usr/bin/fuser $RPM_BUILD_ROOT/bin/ +%ifarch %nopeek +rm -f $RPM_BUILD_ROOT%{_mandir}/man1/peekfd.1* +%endif +%find_lang psmisc + + +%clean +rm -rf $RPM_BUILD_ROOT + + +%files -f psmisc.lang +%defattr (-,root,root,755) +/bin/fuser +%{_bindir}/killall +%ifnarch %nopeek +%{_bindir}/peekfd +%endif +%{_bindir}/prtstat +%{_bindir}/pstree +%{_bindir}/pstree.x11 +%{_mandir}/man1/fuser.1* +%{_mandir}/man1/killall.1* +%ifnarch %nopeek +%{_mandir}/man1/peekfd.1* +%endif +%{_mandir}/man1/prtstat.1* +%{_mandir}/man1/pstree.1* + + + +%changelog From fa934c144f79dedbbfba1db449ff3fdb267ef7e3c7efdd22f2ed9e5978692d95 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Mon, 12 Sep 2011 15:50:38 +0000 Subject: [PATCH 4/4] . OBS-URL: https://build.opensuse.org/package/show/Base:System/psmisc?expand=0&rev=38 --- .gitattributes | 2 - _service:download_files:psmisc-22.14.tar.gz | 3 - _service:download_files:psmisc-22.14.tar.gz.1 | 3 - _service:format_spec_file:psmisc.spec | 105 ---- psmisc-22.12-pstree_overflow.patch | 11 - psmisc-22.14-22.15.patch | 489 ++++++++++++++++++ psmisc-22.14-toomuch.dif | 255 --------- psmisc-22.15-timeout.patch | 369 +++++++++++++ psmisc.changes | 12 + psmisc.spec | 18 +- 10 files changed, 881 insertions(+), 386 deletions(-) delete mode 100644 _service:download_files:psmisc-22.14.tar.gz delete mode 100644 _service:download_files:psmisc-22.14.tar.gz.1 delete mode 100644 _service:format_spec_file:psmisc.spec delete mode 100644 psmisc-22.12-pstree_overflow.patch create mode 100644 psmisc-22.14-22.15.patch delete mode 100644 psmisc-22.14-toomuch.dif create mode 100644 psmisc-22.15-timeout.patch diff --git a/.gitattributes b/.gitattributes index 3997efa..9b03811 100644 --- a/.gitattributes +++ b/.gitattributes @@ -21,5 +21,3 @@ *.xz filter=lfs diff=lfs merge=lfs -text *.zip filter=lfs diff=lfs merge=lfs -text *.zst filter=lfs diff=lfs merge=lfs -text -## Specific LFS patterns -_service:download_files:psmisc-22.14.tar.gz.1 filter=lfs diff=lfs merge=lfs -text diff --git a/_service:download_files:psmisc-22.14.tar.gz b/_service:download_files:psmisc-22.14.tar.gz deleted file mode 100644 index 4571830..0000000 --- a/_service:download_files:psmisc-22.14.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:22bbf4561837af475c0d8d14e3b9cab453998c787212c107fac7faf2f281e26e -size 382024 diff --git a/_service:download_files:psmisc-22.14.tar.gz.1 b/_service:download_files:psmisc-22.14.tar.gz.1 deleted file mode 100644 index 4571830..0000000 --- a/_service:download_files:psmisc-22.14.tar.gz.1 +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:22bbf4561837af475c0d8d14e3b9cab453998c787212c107fac7faf2f281e26e -size 382024 diff --git a/_service:format_spec_file:psmisc.spec b/_service:format_spec_file:psmisc.spec deleted file mode 100644 index 29c2ebb..0000000 --- a/_service:format_spec_file:psmisc.spec +++ /dev/null @@ -1,105 +0,0 @@ -# -# spec file for package psmisc -# -# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. -# -# All modifications and additions to the file contributed by third parties -# remain the property of their copyright owners, unless otherwise agreed -# upon. The license for this file, and modifications and additions to the -# file, is the same license as for the pristine package itself (unless the -# license for the pristine package is not an Open Source License, in which -# case the license is the MIT License). An "Open Source License" is a -# license that conforms to the Open Source Definition (Version 1.9) -# published by the Open Source Initiative. - -# Please submit bugfixes or comments via http://bugs.opensuse.org/ -# - -# norootforbuild - - -Name: psmisc -BuildRequires: gcc-c++ glibc-devel ncurses-devel -BuildRequires: libselinux-devel -Url: http://sourceforge.net/projects/psmisc/ -License: GPLv2+ -Group: System/Monitoring -PreReq: %fillup_prereq %insserv_prereq -Version: 22.14 -Release: 1 -Provides: ps:/usr/bin/killall -Summary: Utilities for managing processes on your system -Source: http://sourceforge.net/projects/psmisc/files/psmisc/%{name}-%{version}.tar.gz -Patch0: %name-22.14.dif -Patch1: %name-22.12-tigetstr.patch -Patch2: %name-22.12-pstree_overflow.patch -Patch3: %name-22.12-pstree.patch -Patch4: %name-22.14-toomuch.dif - -BuildRoot: %{_tmppath}/%{name}-%{version}-build -%define nopeek s390 s390x ia64 %sparc hppa - - -%description -The psmisc package contains utilities for managing processes on your -system: pstree, killall and fuser. The pstree command displays a tree -structure of all of the running processes on your system. The killall -command sends a specified signal (SIGTERM if nothing is specified) to -processes identified by name. The fuser command identifies the PIDs of -processes that are using specified files or filesystems. - -%prep -%setup -q -%patch1 -p0 -b .tigetstr -%patch2 -p0 -b .pstreeovfl -%patch3 -p0 -b .pstree -%patch4 -p0 -b .2much -%patch0 -p0 -b .0 - - -%build -autoreconf -fi -CFLAGS="-D_GNU_SOURCE ${RPM_OPT_FLAGS} -pipe" -CXXFLAGS="$CFLAGS" -CC=gcc -CXX=g++ -export CFLAGS CXXFLAGS CC CXX -sh ./configure --prefix=%{_prefix} --mandir=%{_mandir} --enable-selinux -make %{?_smp_mflags} CFLAGS="$CFLAGS" "CC=$CC" - - -%install -make DESTDIR=$RPM_BUILD_ROOT install -mkdir -p $RPM_BUILD_ROOT/bin/ -mv $RPM_BUILD_ROOT/usr/bin/fuser $RPM_BUILD_ROOT/bin/ -%ifarch %nopeek -rm -f $RPM_BUILD_ROOT%{_mandir}/man1/peekfd.1* -%endif -%find_lang psmisc - - -%clean -rm -rf $RPM_BUILD_ROOT - - -%files -f psmisc.lang -%defattr (-,root,root,755) -/bin/fuser -%{_bindir}/killall -%ifnarch %nopeek -%{_bindir}/peekfd -%endif -%{_bindir}/prtstat -%{_bindir}/pstree -%{_bindir}/pstree.x11 -%{_mandir}/man1/fuser.1* -%{_mandir}/man1/killall.1* -%ifnarch %nopeek -%{_mandir}/man1/peekfd.1* -%endif -%{_mandir}/man1/prtstat.1* -%{_mandir}/man1/pstree.1* - - - -%changelog diff --git a/psmisc-22.12-pstree_overflow.patch b/psmisc-22.12-pstree_overflow.patch deleted file mode 100644 index 36dc40c..0000000 --- a/psmisc-22.12-pstree_overflow.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- src/pstree.c -+++ src/pstree.c 2010-07-13 10:18:31.454925471 +0000 -@@ -69,7 +69,7 @@ extern const char *__progname; - #define VT_HD "w" - - typedef struct _proc { -- char comm[COMM_LEN + 1]; -+ char comm[COMM_LEN + 2 + 1]; /* add another 2 for thread brackets */ - char **argv; /* only used : argv[0] is 1st arg; undef if argc < 1 */ - int argc; /* with -a : number of arguments, -1 if swapped */ - pid_t pid; diff --git a/psmisc-22.14-22.15.patch b/psmisc-22.14-22.15.patch new file mode 100644 index 0000000..bf6cefe --- /dev/null +++ b/psmisc-22.14-22.15.patch @@ -0,0 +1,489 @@ +diff --git a/ChangeLog b/ChangeLog +index f10cea1..e5c36fe 100644 +--- a/ChangeLog ++++ b/ChangeLog +@@ -1,6 +1,14 @@ ++Changes in 22.15 ++================ ++ * Really apply patch for SF#31110178 RH#651794 ++ * Conditionally use fork before stat calls ++ * Patch from Corrina Vinschen for compiling on cygwin ++ * Remove doubled content in src/lists.h ++ * Add another 2 for thread brackets in pstree.c ++ + Changes in 22.14 + ================ +- * Fix file descriptor as weel as memory leaks in fuser ++ * Fix file descriptor as well as memory leaks in fuser + * Strip @ symbol from file names read from /proc/net/unix + * Above 2 changes close openSuSE bugs #536209, #529520, and #417841 + and provided by Werner Fink +diff --git a/README b/README +index 2489b05..2bc973f 100644 +--- a/README ++++ b/README +@@ -17,6 +17,13 @@ They should work with most recent kernels. Man pages are included. + src/loop.h was stolen from util-linux package which in turn stole it from + the Linux kernel. + ++fuser on network fs ++------------------- ++On network filesystems, fuser can hang because its trying to stat files ++that may go away. If you use the --with-timeout-stat option during ++the configure step then fuser will fork a process to run stat. This means ++fuser doesn't hang, but it is much slower. ++ + Translations + ------------ + My thanks for the various translators who have cheerfully given me the po +diff --git a/configure.ac b/configure.ac +index d9013d5..6177975 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -24,6 +24,16 @@ if test "$enable_selinux" = "yes"; then + fi + AC_SUBST([SELINUX_LIB]) + ++dnl Call fork before all stat calls to stop hanging on NFS mounts ++AC_SUBST([WITH_TIMEOUT_STAT]) ++AC_ARG_ENABLE([TIMEOUT_STAT], ++ [AS_HELP_STRING([--enable-timeout-stat], [Use a timeout on stat calls])], ++ [enable_timeout_stat=$enableval], ++ [enable_timeout_stat="no"]) ++if test "$enable_timeout_stat" = "yes"; then ++ AC_DEFINE([WITH_timeout_stat], [1], [Use timeout on stat calls]) ++fi ++ + dnl ipv4 only option + AC_SUBST([WITH_IPV6]) + AC_ARG_ENABLE([ipv6], +@@ -112,7 +122,7 @@ AC_FUNC_MALLOC + AC_FUNC_MEMCMP + AC_FUNC_REALLOC + AC_FUNC_STAT +-AC_CHECK_FUNCS([atexit getmntent memset nl_langinfo regcomp rpmatch setlocale socket strcasecmp strchr strdup strerror strpbrk strrchr strtoul]) ++AC_CHECK_FUNCS([atexit getmntent memset nl_langinfo rawmemchr regcomp rpmatch setlocale socket strcasecmp strchr strdup strerror strpbrk strrchr strtoul]) + + dnl Checks for Large File System + AC_SYS_LARGEFILE +diff --git a/src/Makefile.am b/src/Makefile.am +index 7cff9fd..4398631 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -23,21 +23,24 @@ if WANT_PEEKFD_MIPS + AM_CFLAGS += -DMIPS + endif + +- + fuser_SOURCES = fuser.c comm.h signals.c signals.h i18n.h fuser.h lists.h + ++fuser_LDADD = @LIBINTL@ ++ + killall_SOURCES = killall.c comm.h signals.c signals.h i18n.h + +-killall_LDADD = @SELINUX_LIB@ ++killall_LDADD = @LIBINTL@ @SELINUX_LIB@ + + peekfd_SOURCES = peekfd.c + + pstree_SOURCES = pstree.c comm.h i18n.h + +-pstree_LDADD = @TERMCAP_LIB@ @SELINUX_LIB@ ++pstree_LDADD = @LIBINTL@ @TERMCAP_LIB@ @SELINUX_LIB@ + + prtstat_SOURCES = prtstat.c prtstat.h + ++prtstat_LDADD = @LIBINTL@ ++ + BUILT_SOURCES = signames.h + + EXTRA_DIST = signames.c +diff --git a/Makefile.in b/Makefile.in +--- a/Makefile.in ++++ b/Makefile.in +@@ -169,6 +169,7 @@ USE_NLS = @USE_NLS@ + VERSION = @VERSION@ + WITH_IPV6 = @WITH_IPV6@ + WITH_SELINUX = @WITH_SELINUX@ ++WITH_TIMEOUT_STAT = @WITH_TIMEOUT_STAT@ + XGETTEXT = @XGETTEXT@ + XGETTEXT_015 = @XGETTEXT_015@ + abs_builddir = @abs_builddir@ +diff --git a/src/fuser.c b/src/fuser.c +index 5f27179..476fdf1 100644 +--- a/src/fuser.c ++++ b/src/fuser.c +@@ -48,6 +48,12 @@ + #include + #include + #include ++#include ++/* MAXSYMLINKS is a BSDism. If it doesn't exist, fall back to SYMLINK_MAX, ++ which is the POSIX name. */ ++#ifndef MAXSYMLINKS ++#define MAXSYMLINKS SYMLINK_MAX ++#endif + + #include "fuser.h" + #include "signals.h" +@@ -106,7 +112,11 @@ static dev_t device(const char *path); + static char *expandpath(const char *path); + + typedef int (*stat_t)(const char*, struct stat*); ++#ifdef WITH_TIMEOUT_STAT + static int timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds); ++#else ++#define timeout(func,path,buf,dummy) (func)((path),(buf)) ++#endif /* WITH_TIMEOUT_STAT */ + + static void usage(const char *errormsg) + { +@@ -1160,8 +1170,13 @@ print_matches(struct names *names_head, const opt_type opts, + + for (nptr = names_head; nptr != NULL; nptr = nptr->next) { + if (opts & OPT_SILENT) { +- if (nptr->matched_procs != NULL) +- have_match = 1; ++ for (pptr = nptr->matched_procs; pptr != NULL; ++ pptr = pptr->next) { ++ if(pptr->proc_type != PTYPE_NORMAL) ++ continue; ++ ++ have_match = 1; ++ } + } else { /* We're not silent */ + if ((opts & OPT_ALLFILES) == 0) { + name_has_procs = 0; +@@ -1222,7 +1237,7 @@ print_matches(struct names *names_head, const opt_type opts, + pwent->pw_name); + } + if (pptr->proc_type == PTYPE_NORMAL) +- printf("%6d", pptr->pid); ++ printf(" %5d", pptr->pid); + else + printf("kernel"); + fflush(stdout); +@@ -1316,12 +1331,11 @@ static struct stat *get_pidstat(const pid_t pid, const char *filename) + if ((st = (struct stat*)malloc(sizeof(struct stat))) == NULL) + return NULL; + snprintf(pathname, 256, "/proc/%d/%s", pid, filename); +- if (timeout(stat, pathname, st, 5) != 0) +- goto out; ++ if (timeout(stat, pathname, st, 5) != 0) { ++ free(st); ++ return NULL; ++ } + return st; +-out: +- free(st); +- return NULL; + } + + static void +@@ -1778,6 +1792,7 @@ sigalarm(int sig) + siglongjmp(jenv, 1); + } + ++#ifdef HAVE_TIMEOUT_STAT + static int + timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds) + { +@@ -1826,6 +1841,7 @@ timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds) + err: + return -1; + } ++#endif /* HAVE_TIMEOUT_STAT */ + + #ifdef _LISTS_H + /* +@@ -1967,7 +1983,11 @@ char* expandpath(const char * path) + if (*path != '/') { + if (!getcwd(curr, PATH_MAX)) + return (char*)0; ++#ifdef HAVE_RAWMEMCHR + dest = rawmemchr(curr, '\0'); ++#else ++ dest = strchr(curr, '\0'); ++#endif + } else { + *curr = '/'; + dest = curr + 1; +diff --git a/src/lists.h b/src/lists.h +index d91bbdf..5081e25 100644 +--- a/src/lists.h ++++ b/src/lists.h +@@ -68,256 +68,7 @@ extern inline void attribute((used,__gnu_inline__,always_inline,__artificial__)) + asm volatile ("lfetch [%0]" :: "r" (x)) + #elif defined(__powerpc64__) + asm volatile ("dcbt 0,%0" :: "r" (x)) +-#elif 1 && defined(__i386__) +- asm volatile ("661:\n\t" +- ".byte 0x8d,0x74,0x26,0x00\n" +- "\n662:\n" +- ".section .altinstructions,\"a\"\n" +- " .align 4\n" +- " .long 661b\n" +- " .long 663f\n" +- " .byte %c0\n" +- " .byte 662b-661b\n" +- " .byte 664f-663f\n" +- ".previous\n" +- ".section .altinstr_replacement,\"ax\"\n" +- " 663:\n\t" +- " prefetchnta (%1)" +- " \n664:\n" +- ".previous" +- :: "i" ((0*32+25)), "r" (x)) +-#else +- __builtin_prefetch ((x), 0, 1); +-#endif +- ; +-} +- +-#if defined(DEBUG) && (DEBUG > 0) +-# define __align attribute((packed)) +-#else +-# define __align attribute((aligned(sizeof(struct list_struct*)))) +-#endif +-#define __packed attribute((packed)) +- +-#define alignof(type) ((sizeof(type)+(sizeof(void*)-1)) & ~(sizeof(void*)-1)) +-#define strsize(string) ((strlen(string)+1)*sizeof(char)) +- +-typedef struct list_struct { +- struct list_struct * next, * prev; +-} __align list_t; +- +-/* +- * Linked list handling +- * ==================== +- * The structures which will be linked into such lists have to be of the +- * same type. The structures may have alway a list identifier of the type +- * `list_t' as very first element. With this the macro list_entry() can +- * be used to cast the memory address of a list member to the corresponding +- * allocated structure. +- */ +- +-/* +- * Insert new entry as next member. +- */ +-static inline void _insert(list_t *restrict new, list_t *restrict here) attribute((always_inline,nonnull(1,2))); +-static inline void _insert(list_t *restrict new, list_t *restrict here) +-{ +- list_t * prev = here; +- list_t * next = here->next; +- +- next->prev = new; +- new->next = next; +- new->prev = prev; +- prev->next = new; +-} +- +-#define insert(new, list) _insert(&((new)->this), (&(list))); +-#define append(new, list) _insert(&((new)->this), (&(list))->prev); +- +-/* +- * Set head +- */ +-static inline void initial(list_t *restrict head) attribute((always_inline,nonnull(1))); +-static inline void initial(list_t *restrict head) +-{ +- head->prev = head->next = head; +-} +- +-/* +- * Remove entries, note that the pointer its self remains. +- */ +-static inline void delete(list_t *restrict entry) attribute((always_inline,nonnull(1))); +-static inline void delete(list_t *restrict entry) +-{ +- list_t * prev = entry->prev; +- list_t * next = entry->next; +- +- next->prev = prev; +- prev->next = next; +- +- initial(entry); +-} +- +-/* +- * Replace an entry by a new one. +- */ +-static inline void replace(list_t *restrict old, list_t *restrict new) attribute((always_inline,nonnull(1,2))); +-static inline void replace(list_t *restrict old, list_t *restrict new) +-{ +- new->next = old->next; +- new->next->prev = new; +- new->prev = old->prev; +- new->prev->next = new; +-} +- +-static inline void join(list_t *restrict list, list_t *restrict head) attribute((always_inline,nonnull(1,2))); +-static inline void join(list_t *restrict list, list_t *restrict head) +-{ +- list_t * first = list->next; +- +- if (first != list) { +- list_t * last = list->prev; +- list_t * at = head->next; +- +- first->prev = head; +- head->next = first; +- +- last->next = at; +- at->prev = last; +- } +-} +- +-static inline boolean list_empty(const list_t *restrict const head) attribute((always_inline,nonnull(1))); +-static inline boolean list_empty(const list_t *restrict const head) +-{ +- return head->next == head; +-} +- +-static inline void move_head(list_t *restrict entry, list_t *restrict head) attribute((always_inline,nonnull(1,2))); +-static inline void move_head(list_t *restrict entry, list_t *restrict head) +-{ +- list_t * prev = entry->prev; +- list_t * next = entry->next; +- +- next->prev = prev; /* remove entry from old list */ +- prev->next = next; +- +- prev = head; +- next = head->next; +- +- next->prev = entry; /* and add it at head of new list */ +- entry->next = next; +- entry->prev = prev; +- prev->next = entry; +-} +- +-static inline void move_tail(list_t *restrict entry, list_t *restrict head) attribute((always_inline,nonnull(1,2))); +-static inline void move_tail(list_t *restrict entry, list_t *restrict head) +-{ +- list_t * prev = entry->prev; +- list_t * next = entry->next; +- +- next->prev = prev; /* remove entry from old list */ +- prev->next = next; +- +- prev = head->prev; +- next = head; +- +- next->prev = entry; /* and add it at tail of new list */ +- entry->next = next; +- entry->prev = prev; +- prev->next = entry; +-} +- +-/* +- * The handle of the list is named `this' +- */ +-#define list_entry(ptr, type) (__extension__ ({ \ +- const typeof( ((type *)0)->this ) *__mptr = (ptr); \ +- ((type *)( (char *)(__mptr) - offsetof(type,this) )); })) +-#define list_for_each(pos, head) \ +- for (pos = (head)->next; prefetch(pos->next), pos != (head); pos = pos->next) +-#define np_list_for_each(pos, head) \ +- for (pos = (head)->next; pos != (head); pos = pos->next) +-#define list_for_each_safe(pos, safe, head) \ +- for (pos = (head)->next, safe = pos->next; pos != (head); pos = safe, safe = pos->next) +-#define list_for_each_prev(pos, head) \ +- for (pos = (head)->prev; prefetch(pos->prev), pos != (head); pos = pos->prev) +-#define np_list_for_each_prev(pos, head) \ +- for (pos = (head)->prev; pos != (head); pos = pos->prev) +- +-#endif /* _LISTS_H */ +-/* +- * lists.h Simple doubly linked list implementation, +- * based on and . +- * +- * Version: 0.1 01-Feb-2011 Fink +- * +- * Copyright 2011 Werner Fink, 2005 SUSE LINUX Products GmbH, Germany. +- * +- * This program is free software; you can redistribute it and/or modify +- * it under the terms of the GNU General Public License as published by +- * the Free Software Foundation; either version 2 of the License, or +- * (at your option) any later version. +- * +- * Author: Werner Fink , 2011 +- */ +- +-#ifndef _LISTS_H +-#define _LISTS_H +- +-#include +-#include +- +-typedef enum _boolean {false, true} boolean; +-typedef unsigned char uchar; +-#ifndef __USE_MISC +-typedef unsigned short ushort; +-typedef unsigned int uint; +-#endif +- +-#ifndef __OPTIMIZE__ +-# warning This will not compile without -O at least +-#endif +-#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) +-# ifndef inline +-# define inline __inline__ +-# endif +-# ifndef restrict +-# define restrict __restrict__ +-# endif +-# ifndef volatile +-# define volatile __volatile__ +-# endif +-# ifndef asm +-# define asm __asm__ +-# endif +-# ifndef extension +-# define extension __extension__ +-# endif +-#endif +-#ifndef attribute +-# define attribute(attr) __attribute__(attr) +-#endif +- +-/* +- * This is lent from the kernel by e.g. using +- * +- * echo '#include \nint main () { prefetch(); return 0; }' | \ +- * gcc -I/usr/src/linux/include -D__KERNEL__ -x c -E -P - | \ +- * sed -rn '/void[[:blank:]]+prefetch[[:blank:]]*\(/,/^}/p' +- * +- * on the appropiate architecture (here on i686 for i586). +- */ +-extern inline void attribute((used,__gnu_inline__,always_inline,__artificial__)) prefetch(const void *restrict x) +-{ +-#if defined(__x86_64__) +- asm volatile ("prefetcht0 %0" :: "m" (*(unsigned long *)x)) +-#elif defined(__ia64__) +- asm volatile ("lfetch [%0]" :: "r" (x)) +-#elif defined(__powerpc64__) +- asm volatile ("dcbt 0,%0" :: "r" (x)) +-#elif 1 && defined(__i386__) ++#elif !defined(__CYGWIN__) && defined(__i386__) + asm volatile ("661:\n\t" + ".byte 0x8d,0x74,0x26,0x00\n" + "\n662:\n" +diff --git a/src/pstree.c b/src/pstree.c +index 39f345b..452f823 100644 +--- a/src/pstree.c ++++ b/src/pstree.c +@@ -680,10 +680,10 @@ static void read_proc(void) + + if ((taskdir = opendir(taskpath)) != 0) { + /* if we have this dir, we're on 2.6 */ +- if (! (threadname = malloc(COMM_LEN+1))) { ++ if (! (threadname = malloc(COMM_LEN + 2 + 1))) { + exit(2); + } +- sprintf(threadname, "{%.*s}", COMM_LEN-2, comm); ++ sprintf(threadname, "{%.*s}", COMM_LEN, comm); + while ((dt = readdir(taskdir)) != NULL) { + if ((thread = atoi(dt->d_name)) != 0) { + if (thread != pid) { diff --git a/psmisc-22.14-toomuch.dif b/psmisc-22.14-toomuch.dif deleted file mode 100644 index a8af6f8..0000000 --- a/psmisc-22.14-toomuch.dif +++ /dev/null @@ -1,255 +0,0 @@ ---- src/lists.h -+++ src/lists.h 2011-06-21 13:38:35.696426015 +0000 -@@ -247,252 +247,3 @@ static inline void move_tail(list_t *res - for (pos = (head)->prev; pos != (head); pos = pos->prev) - - #endif /* _LISTS_H */ --/* -- * lists.h Simple doubly linked list implementation, -- * based on and . -- * -- * Version: 0.1 01-Feb-2011 Fink -- * -- * Copyright 2011 Werner Fink, 2005 SUSE LINUX Products GmbH, Germany. -- * -- * This program is free software; you can redistribute it and/or modify -- * it under the terms of the GNU General Public License as published by -- * the Free Software Foundation; either version 2 of the License, or -- * (at your option) any later version. -- * -- * Author: Werner Fink , 2011 -- */ -- --#ifndef _LISTS_H --#define _LISTS_H -- --#include --#include -- --typedef enum _boolean {false, true} boolean; --typedef unsigned char uchar; --#ifndef __USE_MISC --typedef unsigned short ushort; --typedef unsigned int uint; --#endif -- --#ifndef __OPTIMIZE__ --# warning This will not compile without -O at least --#endif --#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) --# ifndef inline --# define inline __inline__ --# endif --# ifndef restrict --# define restrict __restrict__ --# endif --# ifndef volatile --# define volatile __volatile__ --# endif --# ifndef asm --# define asm __asm__ --# endif --# ifndef extension --# define extension __extension__ --# endif --#endif --#ifndef attribute --# define attribute(attr) __attribute__(attr) --#endif -- --/* -- * This is lent from the kernel by e.g. using -- * -- * echo '#include \nint main () { prefetch(); return 0; }' | \ -- * gcc -I/usr/src/linux/include -D__KERNEL__ -x c -E -P - | \ -- * sed -rn '/void[[:blank:]]+prefetch[[:blank:]]*\(/,/^}/p' -- * -- * on the appropiate architecture (here on i686 for i586). -- */ --extern inline void attribute((used,__gnu_inline__,always_inline,__artificial__)) prefetch(const void *restrict x) --{ --#if defined(__x86_64__) -- asm volatile ("prefetcht0 %0" :: "m" (*(unsigned long *)x)) --#elif defined(__ia64__) -- asm volatile ("lfetch [%0]" :: "r" (x)) --#elif defined(__powerpc64__) -- asm volatile ("dcbt 0,%0" :: "r" (x)) --#elif 1 && defined(__i386__) -- asm volatile ("661:\n\t" -- ".byte 0x8d,0x74,0x26,0x00\n" -- "\n662:\n" -- ".section .altinstructions,\"a\"\n" -- " .align 4\n" -- " .long 661b\n" -- " .long 663f\n" -- " .byte %c0\n" -- " .byte 662b-661b\n" -- " .byte 664f-663f\n" -- ".previous\n" -- ".section .altinstr_replacement,\"ax\"\n" -- " 663:\n\t" -- " prefetchnta (%1)" -- " \n664:\n" -- ".previous" -- :: "i" ((0*32+25)), "r" (x)) --#else -- __builtin_prefetch ((x), 0, 1); --#endif -- ; --} -- --#if defined(DEBUG) && (DEBUG > 0) --# define __align attribute((packed)) --#else --# define __align attribute((aligned(sizeof(struct list_struct*)))) --#endif --#define __packed attribute((packed)) -- --#define alignof(type) ((sizeof(type)+(sizeof(void*)-1)) & ~(sizeof(void*)-1)) --#define strsize(string) ((strlen(string)+1)*sizeof(char)) -- --typedef struct list_struct { -- struct list_struct * next, * prev; --} __align list_t; -- --/* -- * Linked list handling -- * ==================== -- * The structures which will be linked into such lists have to be of the -- * same type. The structures may have alway a list identifier of the type -- * `list_t' as very first element. With this the macro list_entry() can -- * be used to cast the memory address of a list member to the corresponding -- * allocated structure. -- */ -- --/* -- * Insert new entry as next member. -- */ --static inline void _insert(list_t *restrict new, list_t *restrict here) attribute((always_inline,nonnull(1,2))); --static inline void _insert(list_t *restrict new, list_t *restrict here) --{ -- list_t * prev = here; -- list_t * next = here->next; -- -- next->prev = new; -- new->next = next; -- new->prev = prev; -- prev->next = new; --} -- --#define insert(new, list) _insert(&((new)->this), (&(list))); --#define append(new, list) _insert(&((new)->this), (&(list))->prev); -- --/* -- * Set head -- */ --static inline void initial(list_t *restrict head) attribute((always_inline,nonnull(1))); --static inline void initial(list_t *restrict head) --{ -- head->prev = head->next = head; --} -- --/* -- * Remove entries, note that the pointer its self remains. -- */ --static inline void delete(list_t *restrict entry) attribute((always_inline,nonnull(1))); --static inline void delete(list_t *restrict entry) --{ -- list_t * prev = entry->prev; -- list_t * next = entry->next; -- -- next->prev = prev; -- prev->next = next; -- -- initial(entry); --} -- --/* -- * Replace an entry by a new one. -- */ --static inline void replace(list_t *restrict old, list_t *restrict new) attribute((always_inline,nonnull(1,2))); --static inline void replace(list_t *restrict old, list_t *restrict new) --{ -- new->next = old->next; -- new->next->prev = new; -- new->prev = old->prev; -- new->prev->next = new; --} -- --static inline void join(list_t *restrict list, list_t *restrict head) attribute((always_inline,nonnull(1,2))); --static inline void join(list_t *restrict list, list_t *restrict head) --{ -- list_t * first = list->next; -- -- if (first != list) { -- list_t * last = list->prev; -- list_t * at = head->next; -- -- first->prev = head; -- head->next = first; -- -- last->next = at; -- at->prev = last; -- } --} -- --static inline boolean list_empty(const list_t *restrict const head) attribute((always_inline,nonnull(1))); --static inline boolean list_empty(const list_t *restrict const head) --{ -- return head->next == head; --} -- --static inline void move_head(list_t *restrict entry, list_t *restrict head) attribute((always_inline,nonnull(1,2))); --static inline void move_head(list_t *restrict entry, list_t *restrict head) --{ -- list_t * prev = entry->prev; -- list_t * next = entry->next; -- -- next->prev = prev; /* remove entry from old list */ -- prev->next = next; -- -- prev = head; -- next = head->next; -- -- next->prev = entry; /* and add it at head of new list */ -- entry->next = next; -- entry->prev = prev; -- prev->next = entry; --} -- --static inline void move_tail(list_t *restrict entry, list_t *restrict head) attribute((always_inline,nonnull(1,2))); --static inline void move_tail(list_t *restrict entry, list_t *restrict head) --{ -- list_t * prev = entry->prev; -- list_t * next = entry->next; -- -- next->prev = prev; /* remove entry from old list */ -- prev->next = next; -- -- prev = head->prev; -- next = head; -- -- next->prev = entry; /* and add it at tail of new list */ -- entry->next = next; -- entry->prev = prev; -- prev->next = entry; --} -- --/* -- * The handle of the list is named `this' -- */ --#define list_entry(ptr, type) (__extension__ ({ \ -- const typeof( ((type *)0)->this ) *__mptr = (ptr); \ -- ((type *)( (char *)(__mptr) - offsetof(type,this) )); })) --#define list_for_each(pos, head) \ -- for (pos = (head)->next; prefetch(pos->next), pos != (head); pos = pos->next) --#define np_list_for_each(pos, head) \ -- for (pos = (head)->next; pos != (head); pos = pos->next) --#define list_for_each_safe(pos, safe, head) \ -- for (pos = (head)->next, safe = pos->next; pos != (head); pos = safe, safe = pos->next) --#define list_for_each_prev(pos, head) \ -- for (pos = (head)->prev; prefetch(pos->prev), pos != (head); pos = pos->prev) --#define np_list_for_each_prev(pos, head) \ -- for (pos = (head)->prev; pos != (head); pos = pos->prev) -- --#endif /* _LISTS_H */ diff --git a/psmisc-22.15-timeout.patch b/psmisc-22.15-timeout.patch new file mode 100644 index 0000000..1aed623 --- /dev/null +++ b/psmisc-22.15-timeout.patch @@ -0,0 +1,369 @@ +diff --git a/configure.ac b/configure.ac +index 6177975..d54f0ad 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -26,12 +26,12 @@ AC_SUBST([SELINUX_LIB]) + + dnl Call fork before all stat calls to stop hanging on NFS mounts + AC_SUBST([WITH_TIMEOUT_STAT]) +-AC_ARG_ENABLE([TIMEOUT_STAT], ++AC_ARG_ENABLE([timeout_stat], + [AS_HELP_STRING([--enable-timeout-stat], [Use a timeout on stat calls])], + [enable_timeout_stat=$enableval], + [enable_timeout_stat="no"]) + if test "$enable_timeout_stat" = "yes"; then +- AC_DEFINE([WITH_timeout_stat], [1], [Use timeout on stat calls]) ++ AC_DEFINE([WITH_TIMEOUT_STAT], [1], [Use timeout on stat calls]) + fi + + dnl ipv4 only option +diff --git a/src/Makefile.am b/src/Makefile.am +index 4398631..bbe9170 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -23,7 +23,7 @@ if WANT_PEEKFD_MIPS + AM_CFLAGS += -DMIPS + endif + +-fuser_SOURCES = fuser.c comm.h signals.c signals.h i18n.h fuser.h lists.h ++fuser_SOURCES = fuser.c comm.h signals.c signals.h timeout.c i18n.h fuser.h lists.h timeout.h + + fuser_LDADD = @LIBINTL@ + +diff --git a/src/fuser.c b/src/fuser.c +index 476fdf1..374a17d 100644 +--- a/src/fuser.c ++++ b/src/fuser.c +@@ -111,9 +111,8 @@ static dev_t device(const char *path); + #endif + static char *expandpath(const char *path); + +-typedef int (*stat_t)(const char*, struct stat*); + #ifdef WITH_TIMEOUT_STAT +-static int timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds); ++#include "timeout.h" + #else + #define timeout(func,path,buf,dummy) (func)((path),(buf)) + #endif /* WITH_TIMEOUT_STAT */ +@@ -1779,70 +1778,6 @@ scan_swaps(struct names *names_head, struct inode_list *ino_head, + fclose(fp); + } + +-/* +- * Execute stat(2) system call with timeout to avoid deadlock +- * on network based file systems. +- */ +-static sigjmp_buf jenv; +- +-static void +-sigalarm(int sig) +-{ +- if (sig == SIGALRM) +- siglongjmp(jenv, 1); +-} +- +-#ifdef HAVE_TIMEOUT_STAT +-static int +-timeout(stat_t func, const char *path, struct stat *buf, unsigned int seconds) +-{ +- pid_t pid = 0; +- int ret = 0, pipes[4]; +- ssize_t len; +- +- if (pipe(&pipes[0]) < 0) +- goto err; +- switch ((pid = fork ())) { +- case -1: +- close(pipes[0]); +- close(pipes[1]); +- goto err; +- case 0: +- (void) signal(SIGALRM, SIG_DFL); +- close(pipes[0]); +- if ((ret = func(path, buf)) == 0) +- do len = write(pipes[1], buf, sizeof(struct stat)); +- while (len < 0 && errno == EINTR); +- close(pipes[1]); +- exit(ret); +- default: +- close(pipes[1]); +- if (sigsetjmp(jenv, 1)) { +- (void) alarm(0); +- (void) signal(SIGALRM, SIG_DFL); +- if (waitpid(0, (int*)0, WNOHANG) == 0) +- kill(pid, SIGKILL); +- errno = ETIMEDOUT; +- seconds = 1; +- goto err; +- } +- (void) signal(SIGALRM, sigalarm); +- (void) alarm(seconds); +- if (read(pipes[0], buf, sizeof(struct stat)) == 0) { +- errno = EFAULT; +- ret = -1; +- } +- (void) alarm(0); +- (void) signal(SIGALRM, SIG_DFL); +- close(pipes[0]); +- break; +- } +- return ret; +-err: +- return -1; +-} +-#endif /* HAVE_TIMEOUT_STAT */ +- + #ifdef _LISTS_H + /* + * Use /proc/self/mountinfo of modern linux system to determine +diff --git a/src/timeout.c b/src/timeout.c +index e69de29..3b582a3 100644 +--- a/src/timeout.c ++++ b/src/timeout.c +@@ -0,0 +1,208 @@ ++/* ++ * timout.c Advanced timeout handling for file system calls ++ * to avoid deadlocks on remote file shares. ++ * ++ * Version: 0.1 07-Sep-2011 Fink ++ * ++ * Copyright 2011 Werner Fink, 2011 SUSE LINUX Products GmbH, Germany. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * Author: Werner Fink , 2011 ++ */ ++ ++#ifndef _GNU_SOURCE ++#define _GNU_SOURCE ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ++#include "timeout.h" ++ ++#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ++# ifndef destructor ++# define destructor __destructor__ ++# endif ++# ifndef constructor ++# define constructor __constructor__ ++# endif ++# ifndef inline ++# define inline __inline__ ++# endif ++# ifndef unused ++# define unused __unused__ ++# endif ++# ifndef volatile ++# define volatile __volatile__ ++# endif ++#endif ++#ifndef attribute ++# define attribute(attr) __attribute__(attr) ++#endif ++ ++/* ++ * The structure used for communication between the processes ++ */ ++ ++typedef struct _handle { ++ size_t len; ++ int errcode; ++ struct stat argument; ++ stat_t function; ++ char *path; ++} handle_t; ++ ++static volatile handle_t handle; ++ ++/* ++ * Using a forked process for doing e.g. stat(2) system call as this ++ * allows us to send e.g. SIGKILL to this process if it hangs in `D' ++ * state on a file share due a stalled NFS server. This does not work ++ * with (p)threads as SIGKILL would kill all threads including main. ++ */ ++ ++static volatile pid_t active; ++static int pipes[4] = {-1, -1, -1, -1}; ++ ++static void attribute((constructor)) start(void) ++{ ++ sigset_t sigset, oldset; ++ handle_t handle; ++ ssize_t in; ++ ++ if (pipe(&pipes[0])) ++ goto error; ++ if (pipe(&pipes[2])) ++ goto error; ++ if ((active = fork()) < 0) ++ goto error; ++ if (active) { ++ close(pipes[0]); ++ close(pipes[3]); ++ pipes[0] = pipes[3] = -1; ++ return; ++ } ++ sigemptyset(&sigset); ++ sigaddset(&sigset, SIGALRM); ++ sigprocmask(SIG_BLOCK, &sigset, &oldset); ++ ++ close(pipes[1]); ++ close(pipes[2]); ++ dup2(pipes[0], 0); ++ dup2(pipes[3], 1); ++ close(pipes[0]); ++ close(pipes[3]); ++ pipes[1] = pipes[2] = -1; ++ pipes[0] = pipes[3] = -1; ++ ++ while ((in = read(0, &handle, sizeof(handle_t))) == sizeof(handle_t) && ++ (handle.path = (char*)malloc(handle.len)) && ++ (in = read(0, handle.path, handle.len)) == handle.len) { ++ if (handle.function(handle.path, &handle.argument) < 0) ++ handle.errcode = errno; ++ write(1, &handle.errcode, sizeof(handle.errcode)+sizeof(handle.argument)); ++ free(handle.path); ++ } ++ sigprocmask(SIG_SETMASK, &oldset, NULL); ++ exit(0); ++error: ++ if (pipes[0] >= 0) close(pipes[0]); ++ if (pipes[1] >= 0) close(pipes[1]); ++ if (pipes[2] >= 0) close(pipes[2]); ++ if (pipes[3] >= 0) close(pipes[3]); ++} ++ ++static void /* attribute((destructor)) */ stop(void) ++{ ++ if (active <= 0) ++ return; ++ if (waitpid(active, NULL, WNOHANG) == 0) ++ kill(active, SIGKILL); ++ active = 0; ++} ++ ++static sigjmp_buf jenv; ++static void sigalarm(int sig attribute((unused))) ++{ ++ siglongjmp(jenv, 1); ++} ++ ++/* ++ * External routine ++ */ ++ ++int timeout(stat_t function, const char *path, struct stat *restrict argument, time_t seconds) ++{ ++ struct sigaction old_act, new_act; ++ sigset_t sigset, oldset; ++ handle_t handle; ++ ++ if (active <= 0) { /* Oops, last one failed therefore clear status and restart */ ++ int status; ++ waitpid(-1, &status, WNOHANG); ++ start(); ++ } ++ ++ handle.len = strlen(path) + 1; ++ handle.errcode = 0; ++ handle.argument = *argument; ++ handle.function = function; ++ handle.path = (char*)0; ++ ++ sigemptyset(&sigset); ++ sigaddset(&sigset, SIGALRM); ++ sigprocmask(SIG_UNBLOCK, &sigset, &oldset); ++ ++ memset(&new_act, 0, sizeof(new_act)); ++ sigemptyset(&new_act.sa_mask); ++ new_act.sa_flags = SA_RESETHAND; ++ new_act.sa_handler = sigalarm; ++ ++ if (sigsetjmp(jenv, 1)) ++ goto timed; ++ ++ sigaction(SIGALRM, &new_act, &old_act); ++ alarm(seconds); ++ ++ write(pipes[1], &handle, sizeof(handle_t)); ++ write(pipes[1], path, handle.len); ++ sched_yield(); ++ read(pipes[2], &handle.errcode, sizeof(handle.errcode)+sizeof(handle.argument)); ++ ++ alarm(0); ++ sigaction(SIGALRM, &old_act, NULL); ++ ++ if (handle.errcode) { ++ errno = handle.errcode; ++ goto error; ++ } ++ *argument = handle.argument; ++ sigprocmask(SIG_SETMASK, &oldset, NULL); ++ return 0; ++timed: ++ (void) alarm(0); ++ sigprocmask(SIG_SETMASK, &oldset, NULL); ++ stop(); ++ errno = ETIMEDOUT; ++error: ++ return -1; ++} ++ ++/* ++ * End of timeout.c ++ */ +diff --git a/src/timeout.h b/src/timeout.h +index e69de29..50dd135 100644 +--- a/src/timeout.h ++++ b/src/timeout.h +@@ -0,0 +1,33 @@ ++/* ++ * timout.h Advanced timeout handling for file system calls ++ * to avoid deadlocks on remote file shares. ++ * ++ * Version: 0.1 07-Sep-2011 Fink ++ * ++ * Copyright 2011 Werner Fink, 2011 SUSE LINUX Products GmbH, Germany. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * Author: Werner Fink , 2011 ++ */ ++ ++#ifndef _TIMEOUT_H ++#define _TIMEOUT_H ++ ++#include ++#include ++#include ++ ++#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L) ++# ifndef restrict ++# define restrict __restrict__ ++# endif ++#endif ++ ++typedef int (*stat_t)(const char *, struct stat *restrict); ++extern int timeout(stat_t, const char *, struct stat *restrict, time_t); ++ ++#endif diff --git a/psmisc.changes b/psmisc.changes index 0996957..5b6063f 100644 --- a/psmisc.changes +++ b/psmisc.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Mon Sep 12 14:28:38 UTC 2011 - werner@suse.de + +- Update to pre version 22.15 + + Really apply patch for SF#31110178 RH#651794 + + Conditionally use fork before stat calls + + Patch from Corrina Vinschen for compiling on cygwin + + Remove doubled content in src/lists.h + + Add another 2 for thread brackets in pstree.c +- Change fork before stat calls to be in best case a second process + using two pipes for bidirectional communication with main. + ------------------------------------------------------------------- Tue Jun 21 15:56:45 CEST 2011 - werner@suse.de diff --git a/psmisc.spec b/psmisc.spec index e4a73dc..9da4891 100644 --- a/psmisc.spec +++ b/psmisc.spec @@ -32,9 +32,9 @@ Summary: Utilities for managing processes on your system Source: http://sourceforge.net/projects/psmisc/files/psmisc/%{name}-%{version}.tar.gz Patch0: %name-22.14.dif Patch1: %name-22.12-tigetstr.patch -Patch2: %name-22.12-pstree_overflow.patch -Patch3: %name-22.12-pstree.patch -Patch4: %name-22.14-toomuch.dif +Patch2: %name-22.12-pstree.patch +Patch42: %name-22.14-22.15.patch +Patch43: %name-22.15-timeout.patch BuildRoot: %{_tmppath}/%{name}-%{version}-build %define nopeek s390 s390x ia64 %sparc hppa @@ -49,10 +49,10 @@ processes that are using specified files or filesystems. %prep %setup -q +%patch42 -p1 +%patch43 -p1 %patch1 -p0 -b .tigetstr -%patch2 -p0 -b .pstreeovfl -%patch3 -p0 -b .pstree -%patch4 -p0 -b .2much +%patch2 -p0 -b .pstree %patch0 -p0 -b .0 %build @@ -62,7 +62,11 @@ CXXFLAGS="$CFLAGS" CC=gcc CXX=g++ export CFLAGS CXXFLAGS CC CXX -sh ./configure --prefix=%{_prefix} --mandir=%{_mandir} --enable-selinux +sh ./configure --prefix=%{_prefix} --mandir=%{_mandir} \ + --disable-rpath \ + --with-gnu-ld \ + --enable-selinux \ + --enable-timeout-stat make %{?_smp_mflags} CFLAGS="$CFLAGS" "CC=$CC" %install