77 lines
1.8 KiB
Diff
77 lines
1.8 KiB
Diff
|
--- src/killall5.c
|
||
|
+++ src/killall5.c 2010-03-19 14:29:44.000000000 +0000
|
||
|
@@ -444,6 +444,38 @@ int readarg(FILE *fp, char *buf, int sz)
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
+ * Scan the filedescriptors of pid for /dev/fuse
|
||
|
+ */
|
||
|
+int is_fuse(const char *pid) {
|
||
|
+ DIR *dir;
|
||
|
+ char path[256];
|
||
|
+ char buf[256];
|
||
|
+ struct dirent *d;
|
||
|
+ ssize_t len;
|
||
|
+
|
||
|
+ /* Open /proc/pid/fd/ */
|
||
|
+ snprintf(path, sizeof(path), "/proc/%s/fd", pid);
|
||
|
+ if ((dir = opendir(path)) != NULL) {
|
||
|
+ int dfd = dirfd(dir);
|
||
|
+ /* Walk through the directory. */
|
||
|
+ while ((d = readdir(dir)) != NULL) {
|
||
|
+ if (*d->d_name == '.')
|
||
|
+ continue;
|
||
|
+ /* check for /dev/fuse */
|
||
|
+ if ((len = readlinkat(dfd, d->d_name, buf, sizeof(buf))) > 0) {
|
||
|
+ buf[len] = '\0';
|
||
|
+ if (strcmp("/dev/fuse", buf) == 0)
|
||
|
+ return 1; /* Fuse filesystem */
|
||
|
+ }
|
||
|
+ }
|
||
|
+ closedir(dir);
|
||
|
+ }
|
||
|
+
|
||
|
+ /* Not a fuse filesystem */
|
||
|
+ return 0;
|
||
|
+}
|
||
|
+
|
||
|
+/*
|
||
|
* Read the proc filesystem.
|
||
|
* CWD must be /proc to avoid problems if / is affected by the killing (ie depend on fuse).
|
||
|
*/
|
||
|
@@ -458,6 +490,7 @@ int readproc(int do_stat)
|
||
|
char buf[PATH_MAX+1];
|
||
|
char *s, *q;
|
||
|
unsigned long startcode, endcode;
|
||
|
+ ssize_t len;
|
||
|
int pid, f;
|
||
|
|
||
|
/* Open the /proc directory. */
|
||
|
@@ -608,6 +641,26 @@ int readproc(int do_stat)
|
||
|
p->nfs = 0;
|
||
|
|
||
|
switch (do_stat) {
|
||
|
+ case NO_STAT:
|
||
|
+ if ((len = readlink(path, buf, PATH_MAX)) < 0)
|
||
|
+ break;
|
||
|
+ buf[len] = '\0';
|
||
|
+
|
||
|
+ /* Check for uevent handler, mdmon, and for providers
|
||
|
+ of FUSE filesystems */
|
||
|
+ if ((strncmp(buf, "/sbin/udevd", 11) == 0) ||
|
||
|
+ (strncmp(buf, "/sbin/mdmon", 11) == 0) ||
|
||
|
+ (is_fuse(d->d_name))) {
|
||
|
+ OMIT *restrict optr;
|
||
|
+
|
||
|
+ xmemalign((void*)&optr, sizeof(void*), alignof(OMIT));
|
||
|
+ optr->next = omit;
|
||
|
+ optr->prev = (OMIT*)0;
|
||
|
+ optr->pid = pid;
|
||
|
+ omit = optr;
|
||
|
+ }
|
||
|
+
|
||
|
+ break;
|
||
|
case DO_NETFS:
|
||
|
if ((p->nfs = check4nfs(path, buf)))
|
||
|
break;
|