rpms/psmisc/F-7 psmisc-22.3-fuser-nfs.patch, 1.1, 1.2 psmisc.spec, 1.36, 1.37
Tomas Smetana (tsmetana)
fedora-extras-commits at redhat.com
Tue Aug 21 13:44:38 UTC 2007
Author: tsmetana
Update of /cvs/pkgs/rpms/psmisc/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv9016
Modified Files:
psmisc-22.3-fuser-nfs.patch psmisc.spec
Log Message:
* Tue Aug 21 2007 Tomas Smetana <tsmetana at redhat.com> 22.3-3.1
- update nfs patch
psmisc-22.3-fuser-nfs.patch:
Index: psmisc-22.3-fuser-nfs.patch
===================================================================
RCS file: /cvs/pkgs/rpms/psmisc/F-7/psmisc-22.3-fuser-nfs.patch,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- psmisc-22.3-fuser-nfs.patch 20 Aug 2007 13:36:31 -0000 1.1
+++ psmisc-22.3-fuser-nfs.patch 21 Aug 2007 13:44:35 -0000 1.2
@@ -1,215 +1,177 @@
---- psmisc-22.3/src/fuser.c.nfs 2007-08-20 15:28:37.000000000 +0200
-+++ psmisc-22.3/src/fuser.c 2007-08-20 15:30:50.000000000 +0200
-@@ -57,7 +57,8 @@
- #define NAME_FIELD 20 /* space reserved for file name */
- /* Function defines */
- static void add_matched_proc(struct names *name_list, const pid_t pid, const uid_t uid, const char access);
--static void check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, struct inode_list *ino_head, const uid_t uid, const char access);
-+static void check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
-+ struct inode_list *ino_head, struct mountdev_list *mount_list, const uid_t uid, const char access);
- static void check_map(const pid_t pid, const char *filename, struct device_list *dev_head, struct inode_list *ino_head, const uid_t uid, const char access);
- static struct stat *get_pidstat(const pid_t pid, const char *filename);
- static uid_t getpiduid(const pid_t pid);
-@@ -69,7 +70,7 @@
+diff -Nur psmisc/src/fuser.c psmisc.nfs/src/fuser.c
+--- psmisc/src/fuser.c 2007-08-06 08:29:21.000000000 +0200
++++ psmisc.nfs/src/fuser.c 2007-08-06 08:32:13.000000000 +0200
+@@ -68,7 +68,7 @@
+ static void 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);
+-static void add_device(struct device_list **dev_list, struct names *this_name, dev_t device);
++static void add_device(struct device_list **dev_list, struct names *this_name, dev_t device, DEVICE_TYPE dev_type);
void scan_mount_devices(const opt_type opts, struct mountdev_list **mount_devices);
void fill_unix_cache(struct unixsocket_list **unixsocket_head);
static dev_t find_net_dev(void);
--static void scan_procs(struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head);
-+static void scan_procs(struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head, struct mountdev_list *mount_devices);
- #ifdef NFS_CHECKS
- static void scan_knfsd(struct names *names_head, struct device_list *dev_head);
- #endif /* NFS_CHECKS */
-@@ -122,7 +123,7 @@
- "For more information about these matters, see the files named COPYING.\n"));
+@@ -162,12 +162,15 @@
+ exe_stat = get_pidstat(pid, "exe");
+ /* 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)
++ 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)
++ }
++ 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)
++ }
++ 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) {
+@@ -210,11 +213,11 @@
+ *ino_list = ino_tmp;
}
--static void scan_procs(struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head)
-+static void scan_procs(struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head, struct mountdev_list *mount_devices)
+-static void add_device(struct device_list **dev_list, struct names *this_name, dev_t device)
++static void add_device(struct device_list **dev_list, struct names *this_name, dev_t device, DEVICE_TYPE dev_type)
{
- DIR *topproc_dir;
- struct dirent *topproc_dent;
-@@ -182,9 +183,9 @@
- }
- }
- }
-- check_dir(pid, "lib", dev_head, ino_head, uid, ACCESS_MMAP);
-- check_dir(pid, "mmap", dev_head, ino_head, uid, ACCESS_MMAP);
-- check_dir(pid, "fd", dev_head, ino_head, uid, ACCESS_FILE);
-+ check_dir(pid, "lib", dev_head, ino_head, mount_devices, uid, ACCESS_MMAP);
-+ check_dir(pid, "mmap", dev_head, ino_head, mount_devices, uid, ACCESS_MMAP);
-+ check_dir(pid, "fd", dev_head, ino_head, mount_devices, uid, ACCESS_FILE);
- check_map(pid, "maps", dev_head, ino_head, uid, ACCESS_MMAP);
+ struct device_list *dev_tmp, *dev_head;
- } /* while topproc_dent */
-@@ -837,7 +838,7 @@
+- /*printf("Adding device %s %d\n", this_name->filename, device);*/
++ /*printf("Adding device %s %d\n", this_name->filename, (int) device);*/
+ dev_head = *dev_list;
+
+ if ( (dev_tmp = malloc(sizeof(struct device_list))) == NULL)
+@@ -222,6 +225,7 @@
+ dev_tmp->name = this_name;
+ dev_tmp->device = device;
+ dev_tmp->next = dev_head;
++ dev_tmp->type = dev_type;
+ *dev_list = dev_tmp;
+ }
+
+@@ -321,7 +325,7 @@
#ifdef DEBUG
- debug_match_lists(names_head, match_inodes, match_devices);
- #endif
-- scan_procs(names_head, match_inodes, match_devices);
-+ scan_procs(names_head, match_inodes, match_devices, mount_devices);
- #ifdef NFS_CHECKS
- scan_knfsd(names_head, match_devices);
- #endif /* NFS_CHECKS */
-@@ -951,19 +952,24 @@
- return st;
+ printf("Debug: parse_mount() adding %s\n", this_name->filename);
+ #endif /* DEBUG */
+- add_device(dev_list, this_name, st.st_dev);
++ add_device(dev_list, this_name, st.st_dev, DEV_TYPE_OTHER);
+ return 0;
}
--static void check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, struct inode_list *ino_head, const uid_t uid, const char access)
-+static void check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head,
-+ struct inode_list *ino_head, struct mountdev_list *mount_list, const uid_t uid, const char access)
+@@ -370,6 +374,7 @@
+ struct stat st;
+ struct mountdev_list *mountptr;
+ dev_t match_device;
++ DEVICE_TYPE dev_type;
+
+ if (stat(this_name->filename, &st) != 0) {
+ fprintf(stderr,_("Cannot stat %s: %s\n"), this_name->filename,
+@@ -381,10 +386,15 @@
+ else
+ match_device = st.st_dev;
+ for (mountptr = mounts ; mountptr != NULL ; mountptr = mountptr->next) {
++ if (strcmp(mountptr->fstype, "nfs") == 0) {
++ dev_type = DEV_TYPE_NFS;
++ } else {
++ dev_type = DEV_TYPE_OTHER;
++ }
+ if (mountptr->device == match_device) {
+ /*printf("Debug: adding parse_mounts() adding %s\n",
+ this_name->filename);*/
+- add_device(dev_list, this_name, match_device);
++ add_device(dev_list, this_name, match_device, dev_type);
+ }
+ }
+ return 0;
+@@ -994,7 +1004,7 @@
+
+ static void check_dir(const pid_t pid, const char *dirname, struct device_list *dev_head, struct inode_list *ino_head, const uid_t uid, const char access)
{
- char *dirpath, *filepath;
-+ char *dirpath, *filepath, *realname;
++ char *dirpath, *filepath, *realfile;
DIR *dirp;
struct dirent *direntry;
struct inode_list *ino_tmp;
- struct device_list *dev_tmp;
-+ struct mountdev_list *mnt_tmp;
- struct stat st, lst;
-+ int realname_len, on_nfs, proc_added;
-
- if ( (dirpath = malloc(MAX_PATHNAME)) == NULL)
- return;
- if ( (filepath = malloc(MAX_PATHNAME)) == NULL)
- return;
-+ if ( (realname = malloc(MAX_PATHNAME)) == NULL)
-+ return;
-
- snprintf(dirpath, MAX_PATHNAME, "/proc/%d/%s", pid, dirname);
- if ( (dirp = opendir(dirpath)) == NULL)
-@@ -974,24 +980,61 @@
-
- snprintf(filepath, MAX_PATHNAME, "/proc/%d/%s/%s",
- pid, dirname, direntry->d_name);
-- if (stat(filepath, &st) != 0) {
-- fprintf(stderr, _("Cannot stat file %s: %s\n"),filepath, strerror(errno));
-- } else {
-- for (dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next) {
-- if (st.st_dev == dev_tmp->device) {
+@@ -1020,10 +1030,26 @@
+ } else {
+ 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 ((realname_len = readlink(filepath, realname, MAX_PATHNAME - 1)) == - 1)
-+ {
-+ fprintf(stderr, "Cannot read link %s\n", filepath);
-+ }
-+ realname[realname_len] = '\0';
-+ on_nfs = 0;
-+ proc_added = 0;
-+ for (mnt_tmp = mount_list; mnt_tmp != NULL; mnt_tmp = mnt_tmp->next)
-+ {
-+ if (mnt_tmp->fstype == DEV_TYPE_NFS) {
-+ if (!strncmp(mnt_tmp->dir, realname, strlen(mnt_tmp->dir))) {
-+ on_nfs = 1;
-+ for (dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next) {
-+ if ((!strncmp(mnt_tmp->dir, dev_tmp->name->filename, strlen(mnt_tmp->dir))) &&
-+ (!strncmp(dev_tmp->name->filename, realname, strlen(mnt_tmp->dir)))) {
-+ proc_added = 1;
-+ 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 (dev_tmp->type == DEV_TYPE_NFS) {
++ if ((realfile = (char *)alloca(strlen(dev_tmp->name->filename))) == NULL) {
++ fprintf(stderr, "Cannot allocate buffer memory\n");
+ }
-+ }
-+ }
-+ }
-+ }
-+ if ((!proc_added) && (!on_nfs)) {
-+ if (!on_nfs) {
-+ if (stat(filepath, &st) != 0) {
-+ fprintf(stderr, _("Cannot stat file %s: %s\n"),filepath, strerror(errno));
-+ } else {
-+ for (dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next) {
-+ if (st.st_dev == dev_tmp->device) {
++ if (readlink(filepath, realfile, strlen(dev_tmp->name->filename)) == -1) {
++ fprintf(stderr, "Cannot read link %s\n", filepath);
++ }
++ if (strncmp(dev_tmp->name->filename, realfile, strlen(dev_tmp->name->filename)) == 0) {
+ 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);
+ }
-+ proc_added = 1;
+ }
- }
- }
- }
-- 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 (!proc_added) {
-+ if (stat(filepath, &st) != 0) {
-+ fprintf(stderr, _("Cannot stat file %s: %s\n"),filepath, strerror(errno));
-+ } else {
-+ 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);
-+ }
++ } else {
++ 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);
+ }
}
}
}
-@@ -1041,7 +1084,7 @@
+@@ -1082,7 +1108,7 @@
return st.st_uid;
}
-void add_mount_device(struct mountdev_list **mount_head,const char *fsname, const char *dir, dev_t device)
-+void add_mount_device(struct mountdev_list **mount_head,const char *fsname, const char *dir, dev_t device, DEVICE_TYPE fstype)
++void add_mount_device(struct mountdev_list **mount_head,const char *fsname, const char *fstype, const char *dir, dev_t device)
{
struct mountdev_list *newmount;
/*printf("Adding mount Path: %s Dir:%s dev:%0x\n",dir, fsname, device);*/
-@@ -1049,6 +1092,7 @@
+@@ -1090,6 +1116,7 @@
if ( (newmount = malloc(sizeof(struct mountdev_list))) == NULL)
return;
newmount->fsname = strdup(fsname);
-+ newmount->fstype = fstype;
++ newmount->fstype = strdup(fstype);
newmount->dir = strdup(dir);
newmount->device = device;
newmount->next = *mount_head;
-@@ -1103,6 +1147,7 @@
- FILE *mntfp;
- struct mntent *mnt_ptr;
- struct stat st;
-+ DEVICE_TYPE mnt_type;
-
- if ( (mntfp = setmntent("/etc/mtab","r")) == NULL) {
- fprintf(stderr, _("Cannot open /etc/mtab: %s\n"),
-@@ -1110,8 +1155,14 @@
- return;
+@@ -1152,7 +1179,7 @@
}
while ( (mnt_ptr = getmntent(mntfp)) != NULL) {
-- if (stat(mnt_ptr->mnt_dir, &st) == 0) {
+ if (stat(mnt_ptr->mnt_dir, &st) == 0) {
- add_mount_device(mount_devices, mnt_ptr->mnt_fsname, mnt_ptr->mnt_dir, st.st_dev);
-+ if (!strcmp(mnt_ptr->mnt_type, "nfs")) {
-+ mnt_type = DEV_TYPE_NFS;
-+ add_mount_device(mount_devices, mnt_ptr->mnt_fsname, mnt_ptr->mnt_dir, -1, mnt_type);
-+ } else {
-+ if (stat(mnt_ptr->mnt_dir, &st) == 0) {
-+ mnt_type = DEV_TYPE_OTHER;
-+ add_mount_device(mount_devices, mnt_ptr->mnt_fsname, mnt_ptr->mnt_dir, st.st_dev, mnt_type);
-+ }
++ add_mount_device(mount_devices, mnt_ptr->mnt_fsname, mnt_ptr->mnt_type, mnt_ptr->mnt_dir, st.st_dev);
}
}
}
---- psmisc-22.3/src/fuser.h.nfs 2007-08-20 15:28:42.000000000 +0200
-+++ psmisc-22.3/src/fuser.h 2007-08-20 15:30:50.000000000 +0200
-@@ -58,8 +58,14 @@
- struct inode_list *next;
+diff -Nur psmisc/src/fuser.h psmisc.nfs/src/fuser.h
+--- psmisc/src/fuser.h 2007-08-06 08:29:21.000000000 +0200
++++ psmisc.nfs/src/fuser.h 2007-08-06 08:33:35.000000000 +0200
+@@ -60,14 +60,20 @@
+
+ struct mountdev_list {
+ char *fsname;
++ char *fstype;
+ char *dir;
+ dev_t device;
+ struct mountdev_list *next;
};
+typedef enum {
+ DEV_TYPE_NFS = 0,
+ DEV_TYPE_OTHER
+} DEVICE_TYPE;
-+
- struct mountdev_list {
- char *fsname;
-+ DEVICE_TYPE fstype;
- char *dir;
+
+ struct device_list {
+ struct names *name;
++ DEVICE_TYPE type;
dev_t device;
- struct mountdev_list *next;
+ struct device_list *next;
+ };
Index: psmisc.spec
===================================================================
RCS file: /cvs/pkgs/rpms/psmisc/F-7/psmisc.spec,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -r1.36 -r1.37
--- psmisc.spec 20 Aug 2007 13:36:31 -0000 1.36
+++ psmisc.spec 21 Aug 2007 13:44:35 -0000 1.37
@@ -1,7 +1,7 @@
Summary: Utilities for managing processes on your system
Name: psmisc
Version: 22.3
-Release: 3%{?dist}
+Release: 3.1%{?dist}
License: BSD and GPLv2+
Group: Applications/System
Source: ftp://ftp.sf.net/pub/sourceforge/psmisc/psmisc-%{version}.tar.gz
@@ -31,6 +31,7 @@
%setup -q
%patch0 -p1
%patch1 -p1
+%patch2 -p1
%build
export CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"
@@ -63,6 +64,9 @@
%{_mandir}/man1/pstree.1*
%changelog
+* Tue Aug 21 2007 Tomas Smetana <tsmetana at redhat.com> 22.3-3.1
+- update nfs patch
+
* Mon Aug 20 2007 Tomas Smetana <tsmetana at redhat.com> 22.3-3
- fix #245538 - fuser incorrectly reports processess using nfs filesystems
- update license tag
More information about the scm-commits
mailing list