2008-05-22 04:14:34 +02:00
|
|
|
--- doc/fuser.1
|
2008-08-08 02:14:10 +02:00
|
|
|
+++ doc/fuser.1 2008-05-16 15:18:59.000000000 +0200
|
2008-05-22 04:14:34 +02:00
|
|
|
@@ -80,8 +80,14 @@ List all known signal names.
|
|
|
|
\fIname\fP specifies a file on a mounted file system or a block device that
|
|
|
|
is mounted. All processes accessing files on that file system are listed.
|
|
|
|
If a directory file is specified, it is automatically changed to
|
|
|
|
-\fIname\fP/. to use any file system that might be mounted on that
|
|
|
|
-directory.
|
|
|
|
+\fIname\fP/. To use any file system that might be mounted on that
|
|
|
|
+directory. Please note that due the required device ID comparision all
|
|
|
|
+mounted file systems the
|
|
|
|
+.BR stat (2)
|
|
|
|
+system call will applied to every file system even on network file system
|
|
|
|
+(NFS). If the NFS server does not respond or the network is down the
|
|
|
|
+.BR stat (2)
|
|
|
|
+may hang forever.
|
|
|
|
.IP \fB\-n\ \fIspace\fP
|
|
|
|
Select a different name space. The name spaces \fBfile\fP (file names, the
|
|
|
|
default), \fBudp\fP (local UDP ports), and \fBtcp\fP (local TCP ports) are
|
|
|
|
@@ -152,10 +158,13 @@ The \fB\-k\fP option only works on proce
|
|
|
|
\fBfuser\fP will print an advice, but take no action beyond that.
|
|
|
|
.SH BUGS
|
|
|
|
.PP
|
|
|
|
-fuser \-m /dev/sgX will show (or kill with the \-k flag) all processes, even
|
|
|
|
+\fBfuser \-m \fI/dev/sgX\fR will show (or kill with the \fB\-k\fR flag) all processes, even
|
|
|
|
if you don't have that device configured. There may be other devices it
|
|
|
|
does this for too.
|
|
|
|
.PP
|
|
|
|
+\fBfuser \-m \fIname\fR may hang forever if there are NFS file systems mounted
|
|
|
|
+and one of the NFS servers do not respond or the corresponding network is down.
|
|
|
|
+.PP
|
|
|
|
.B fuser
|
|
|
|
cannot report on any processes that it doesn't have permission to look at
|
|
|
|
the file descriptor table for. The most common time this problem occurs
|
2007-04-26 15:51:55 +02:00
|
|
|
--- src/fuser.c
|
2009-10-12 16:47:10 +02:00
|
|
|
+++ src/fuser.c 2009-05-11 13:45:16.565902120 +0200
|
2008-09-24 17:25:01 +02:00
|
|
|
@@ -32,9 +32,11 @@
|
2007-04-26 15:51:55 +02:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
+#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/socket.h>
|
2008-09-24 17:25:01 +02:00
|
|
|
+#include <sys/wait.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
@@ -45,6 +47,7 @@
|
|
|
|
#include <mntent.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <getopt.h>
|
|
|
|
+#include <setjmp.h>
|
|
|
|
|
|
|
|
#include "fuser.h"
|
|
|
|
#include "signals.h"
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -63,7 +66,7 @@ static void add_matched_proc(struct name
|
|
|
|
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,
|
|
|
|
struct unixsocket_list *sockets, dev_t netdev);
|
2007-04-26 15:51:55 +02:00
|
|
|
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 struct stat *get_pidstat(const opt_type opts, const pid_t pid, const char *filename, char *real);
|
|
|
|
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, const int sig_number);
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -73,13 +76,20 @@ static void add_device(struct device_lis
|
2007-04-26 15:51:55 +02:00
|
|
|
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);
|
2009-05-15 21:46:50 +02:00
|
|
|
-static void scan_procs(struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head, struct unixsocket_list *sockets, dev_t netdev);
|
|
|
|
+static void scan_procs(const opt_type opts, struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head, struct unixsocket_list *sockets, dev_t netdev);
|
2007-04-26 15:51:55 +02:00
|
|
|
#ifdef NFS_CHECKS
|
|
|
|
static void scan_knfsd(struct names *names_head, struct device_list *dev_head);
|
|
|
|
#endif /* NFS_CHECKS */
|
|
|
|
#ifdef DEBUG
|
2008-09-24 17:25:01 +02:00
|
|
|
static void debug_match_lists(struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head);
|
2007-04-26 15:51:55 +02:00
|
|
|
#endif
|
|
|
|
+static struct nfs_points *mnts;
|
2009-04-02 17:29:10 +02:00
|
|
|
+static void clear_mnt(void);
|
2007-04-26 15:51:55 +02:00
|
|
|
+static int check4nfs(const char * path, char * real);
|
2008-09-24 17:25:01 +02:00
|
|
|
+
|
|
|
|
+typedef int (*stat_t)(const char*, struct stat*);
|
|
|
|
+static int nfssafe(stat_t func, const char *path, struct stat *buf);
|
2009-05-15 21:46:50 +02:00
|
|
|
+
|
2007-04-26 15:51:55 +02:00
|
|
|
|
|
|
|
static void usage (const char *errormsg)
|
|
|
|
{
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -127,7 +137,14 @@ void print_version()
|
2007-04-26 15:51:55 +02:00
|
|
|
"For more information about these matters, see the files named COPYING.\n"));
|
|
|
|
}
|
|
|
|
|
2009-05-15 21:46:50 +02:00
|
|
|
-static void scan_procs(struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head, struct unixsocket_list *sockets, dev_t netdev)
|
2008-08-08 02:14:10 +02:00
|
|
|
+static int islocatedon(const char * path, const char * loc)
|
|
|
|
+{
|
|
|
|
+ if (!path || *path == '\0')
|
|
|
|
+ return 0;
|
|
|
|
+ return (strstr(path, loc) == path);
|
|
|
|
+}
|
|
|
|
+
|
2009-05-15 21:46:50 +02:00
|
|
|
+static void scan_procs(const opt_type opts, struct names *names_head, struct inode_list *ino_head, struct device_list *dev_head, struct unixsocket_list *sockets, dev_t netdev)
|
2007-04-26 15:51:55 +02:00
|
|
|
{
|
|
|
|
DIR *topproc_dir;
|
|
|
|
struct dirent *topproc_dent;
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -137,6 +154,9 @@ static void scan_procs(struct names *nam
|
2007-04-26 15:51:55 +02:00
|
|
|
pid_t pid, my_pid;
|
|
|
|
uid_t uid;
|
|
|
|
struct stat *cwd_stat, *exe_stat, *root_stat;
|
|
|
|
+ char root_real[PATH_MAX+1];
|
|
|
|
+ char cwd_real[PATH_MAX+1];
|
|
|
|
+ char exe_real[PATH_MAX+1];
|
|
|
|
|
|
|
|
if ( (fd_dirpath = malloc(MAX_PATHNAME)) == NULL)
|
|
|
|
return;
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -157,9 +177,10 @@ static void scan_procs(struct names *nam
|
2007-04-26 15:51:55 +02:00
|
|
|
continue;
|
|
|
|
uid = getpiduid(pid);
|
|
|
|
|
|
|
|
- root_stat = get_pidstat(pid, "root");
|
|
|
|
- cwd_stat = get_pidstat(pid, "cwd");
|
|
|
|
- exe_stat = get_pidstat(pid, "exe");
|
|
|
|
+ root_real[0] = cwd_real[0] = exe_real[0] = '\0';
|
|
|
|
+ root_stat = get_pidstat(opts, pid, "root", root_real);
|
|
|
|
+ cwd_stat = get_pidstat(opts, pid, "cwd", cwd_real);
|
|
|
|
+ exe_stat = get_pidstat(opts, pid, "exe", exe_real);
|
|
|
|
/* 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)
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -168,6 +189,14 @@ static void scan_procs(struct names *nam
|
2007-04-26 15:51:55 +02:00
|
|
|
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);
|
2008-08-08 02:14:10 +02:00
|
|
|
+ if ((dev_tmp->name->name_space & NAMESPACE_NFS) == 0)
|
|
|
|
+ continue;
|
|
|
|
+ if (islocatedon(&exe_real[0], dev_tmp->name->filename))
|
2007-04-26 15:51:55 +02:00
|
|
|
+ add_matched_proc(dev_tmp->name, pid, uid, ACCESS_EXE);
|
2008-08-08 02:14:10 +02:00
|
|
|
+ if (islocatedon(&root_real[0], dev_tmp->name->filename))
|
2007-04-26 15:51:55 +02:00
|
|
|
+ add_matched_proc(dev_tmp->name, pid, uid, ACCESS_ROOT);
|
2008-08-08 02:14:10 +02:00
|
|
|
+ if (islocatedon(&cwd_real[0], dev_tmp->name->filename))
|
2007-04-26 15:51:55 +02:00
|
|
|
+ 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) {
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -186,9 +215,19 @@ static void scan_procs(struct names *nam
|
2007-04-26 15:51:55 +02:00
|
|
|
add_matched_proc(ino_tmp->name, pid, uid, ACCESS_CWD);
|
|
|
|
}
|
|
|
|
}
|
2008-08-08 02:14:10 +02:00
|
|
|
+ if ((ino_tmp->name->name_space & NAMESPACE_NFS) == 0)
|
|
|
|
+ continue;
|
|
|
|
+ if (islocatedon(&exe_real[0], ino_tmp->name->filename))
|
|
|
|
+ add_matched_proc(ino_tmp->name, pid, uid, ACCESS_EXE);
|
|
|
|
+ if (islocatedon(&root_real[0], ino_tmp->name->filename))
|
|
|
|
+ add_matched_proc(ino_tmp->name, pid, uid, ACCESS_ROOT);
|
|
|
|
+ if (islocatedon(&cwd_real[0], ino_tmp->name->filename))
|
|
|
|
+ add_matched_proc(ino_tmp->name, pid, uid, ACCESS_CWD);
|
2007-04-26 15:51:55 +02:00
|
|
|
}
|
2008-08-08 02:14:10 +02:00
|
|
|
+#ifndef __linux__
|
2009-05-15 21:46:50 +02:00
|
|
|
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);
|
2008-08-08 02:14:10 +02:00
|
|
|
+#endif
|
2009-05-15 21:46:50 +02:00
|
|
|
check_dir(pid, "fd", dev_head, ino_head, uid, ACCESS_FILE, sockets, netdev);
|
2008-08-08 02:14:10 +02:00
|
|
|
check_map(pid, "maps", dev_head, ino_head, uid, ACCESS_MMAP);
|
|
|
|
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -325,10 +364,26 @@ int parse_mount(struct names *this_name,
|
2007-04-26 15:51:55 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-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 opt_type opts)
|
|
|
|
{
|
|
|
|
+ char real[PATH_MAX+1] = "";
|
|
|
|
struct stat st;
|
|
|
|
|
|
|
|
+ real[0] = '\0';
|
|
|
|
+ if (check4nfs(this_name->filename, real)) {
|
|
|
|
+ if ((opts & (OPT_MOUNTPOINT|OPT_MOUNTS)) == 0) {
|
|
|
|
+ free(this_name->filename);
|
|
|
|
+ this_name->filename = strdup(real);
|
2007-12-19 22:14:01 +01:00
|
|
|
+ this_name->name_space |= NAMESPACE_NFS;
|
|
|
|
+ add_inode(ino_list, this_name, (dev_t)-1, (ino_t)-1);
|
2007-04-26 15:51:55 +02:00
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (real[0] != '\0') {
|
|
|
|
+ free(this_name->filename);
|
|
|
|
+ this_name->filename = strdup(real);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
if (stat(this_name->filename, &st) != 0) {
|
|
|
|
fprintf(stderr,_("Cannot stat %s: %s\n"), this_name->filename,
|
|
|
|
strerror(errno));
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -342,34 +397,44 @@ int parse_file(struct names *this_name,
|
2007-04-26 15:51:55 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-int parse_unixsockets(struct names *this_name, struct inode_list **ino_list, struct unixsocket_list *sun_head)
|
|
|
|
+int parse_unixsockets(struct names *this_name, struct inode_list **ino_list, struct unixsocket_list *sun_head, dev_t net_dev, const opt_type opts)
|
|
|
|
{
|
|
|
|
struct unixsocket_list *sun_tmp;
|
|
|
|
struct stat st;
|
|
|
|
- dev_t net_dev;
|
|
|
|
-
|
|
|
|
+
|
2007-12-19 22:14:01 +01:00
|
|
|
+ if (check4nfs(this_name->filename, NULL)) {
|
|
|
|
+ this_name->name_space |= NAMESPACE_NFS;
|
2007-04-26 15:51:55 +02:00
|
|
|
+ return 0;
|
2007-12-19 22:14:01 +01:00
|
|
|
+ }
|
2007-04-26 15:51:55 +02:00
|
|
|
+
|
|
|
|
if (stat(this_name->filename, &st) != 0) {
|
|
|
|
fprintf(stderr,_("Cannot stat %s: %s\n"), this_name->filename,
|
|
|
|
strerror(errno));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
- net_dev = find_net_dev();
|
|
|
|
|
|
|
|
for (sun_tmp = sun_head; sun_tmp != NULL ; sun_tmp = sun_tmp->next)
|
|
|
|
{
|
|
|
|
- if (sun_tmp->dev == st.st_dev && sun_tmp->inode == st.st_ino) {
|
|
|
|
+ if (sun_tmp->dev == st.st_dev && sun_tmp->inode == st.st_ino) {
|
|
|
|
add_inode(ino_list, this_name, net_dev, sun_tmp->net_inode);
|
|
|
|
- return 0;
|
|
|
|
+ return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-int parse_mounts(struct names *this_name, struct mountdev_list *mounts, struct device_list **dev_list, const char opts)
|
|
|
|
+int parse_mounts(struct names *this_name, struct mountdev_list *mounts, struct device_list **dev_list, const opt_type opts)
|
|
|
|
{
|
|
|
|
struct stat st;
|
|
|
|
struct mountdev_list *mountptr;
|
2007-12-19 22:14:01 +01:00
|
|
|
dev_t match_device;
|
|
|
|
+ char real[PATH_MAX+1] = "";
|
|
|
|
+
|
|
|
|
+ real[0] = '\0';
|
|
|
|
+ if (check4nfs(this_name->filename, real)) {
|
|
|
|
+ this_name->name_space |= NAMESPACE_NFS;
|
|
|
|
+ goto skip;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (stat(this_name->filename, &st) != 0) {
|
|
|
|
fprintf(stderr,_("Cannot stat %s: %s\n"), this_name->filename,
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -388,6 +453,16 @@ int parse_mounts(struct names *this_name
|
2007-12-19 22:14:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
+skip:
|
|
|
|
+ match_device = -1;
|
|
|
|
+ for (mountptr = mounts ; mountptr != NULL ; mountptr = mountptr->next) {
|
|
|
|
+ if (strcmp(mountptr->dir, real) == 0) {
|
2008-08-08 02:14:10 +02:00
|
|
|
+ /*printf("Debug: adding parse_mounts() adding %s\n",
|
|
|
|
+ this_name->filename);*/
|
2007-12-19 22:14:01 +01:00
|
|
|
+ add_device(dev_list, this_name, match_device);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef WITH_IPV6
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -652,6 +727,150 @@ void find_net6_sockets(struct inode_list
|
2007-04-26 15:51:55 +02:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2009-04-02 17:29:10 +02:00
|
|
|
+/*
|
|
|
|
+ * Remove struct nfs_points and its sahdows from memory
|
|
|
|
+ */
|
|
|
|
+static void clear_shadow(struct shadow_list *restrict shadow)
|
|
|
|
+{
|
|
|
|
+ struct shadow_list *s, *n, *l;
|
|
|
|
+
|
|
|
|
+ n = shadow;
|
|
|
|
+ l = (struct shadow_list*)0;
|
|
|
|
+ for (s = shadow; n; s = n) {
|
|
|
|
+ l = s->prev;
|
|
|
|
+ n = s->next;
|
|
|
|
+ if (s == shadow) {
|
|
|
|
+ if (n) n->prev = (struct shadow_list*)0;
|
|
|
|
+ shadow = n;
|
|
|
|
+ } else if (l) {
|
|
|
|
+ if (n) n->prev = l;
|
|
|
|
+ l->next = n;
|
|
|
|
+ }
|
|
|
|
+ free(s);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+static void clear_mnt(void)
|
|
|
|
+{
|
|
|
|
+ struct nfs_points *p, *n, *l;
|
|
|
|
+
|
|
|
|
+ n = mnts;
|
|
|
|
+ l = (struct nfs_points*)0;
|
|
|
|
+ for (p = mnts; n; p = n) {
|
|
|
|
+ l = p->prev;
|
|
|
|
+ n = p->next;
|
|
|
|
+ if (p == mnts) {
|
|
|
|
+ if (n) n->prev = (struct nfs_points*)0;
|
|
|
|
+ mnts = n;
|
|
|
|
+ } else if (l) {
|
|
|
|
+ if (n) n->prev = l;
|
|
|
|
+ l->next = n;
|
|
|
|
+ }
|
|
|
|
+ if (p->shadow)
|
|
|
|
+ clear_shadow(p->shadow);
|
|
|
|
+ free(p);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Check if path is ia shadow off a NFS partition.
|
|
|
|
+ */
|
|
|
|
+static int shadow(struct shadow_list *restrict this, const char *restrict name, const size_t nlen)
|
|
|
|
+{
|
|
|
|
+ struct shadow_list *s;
|
|
|
|
+
|
|
|
|
+ if (!this)
|
|
|
|
+ goto out;
|
|
|
|
+ for (s = this; s; s = s->next) {
|
|
|
|
+ if (nlen < s->nlen)
|
|
|
|
+ continue;
|
|
|
|
+ if (name[s->nlen] != '\0' && name[s->nlen] != '/')
|
|
|
|
+ continue;
|
|
|
|
+ if (strncmp(name, s->name, s->nlen) == 0)
|
|
|
|
+ return 1;
|
|
|
|
+ }
|
|
|
|
+out:
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
2007-04-26 15:51:55 +02:00
|
|
|
+/*
|
|
|
|
+ * Check path is located on a NFS partition.
|
|
|
|
+ */
|
|
|
|
+static int check4nfs(const char * path, char * real)
|
|
|
|
+{
|
|
|
|
+ char buf[PATH_MAX+1];
|
|
|
|
+ const char *curr;
|
|
|
|
+ int deep = MAXSYMLINKS;
|
|
|
|
+
|
|
|
|
+ if (!mnts) return 0;
|
|
|
|
+
|
|
|
|
+ curr = path;
|
|
|
|
+ do {
|
|
|
|
+ const char *prev;
|
|
|
|
+ int len;
|
|
|
|
+
|
|
|
|
+ if ((prev = strdupa(curr)) == NULL)
|
|
|
|
+ return 0;
|
|
|
|
+
|
|
|
|
+ errno = 0;
|
|
|
|
+ if ((len = readlink(curr, buf, PATH_MAX)) < 0)
|
|
|
|
+ break;
|
|
|
|
+ buf[len] = '\0'; /* Don't be fooled by readlink(2) */
|
|
|
|
+
|
|
|
|
+ if (strncmp(prev, "/proc/", 6) == 0) {
|
|
|
|
+ curr = &buf[0];
|
|
|
|
+ break; /* /proc/ provides the real path! */
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (len > 10) {
|
|
|
|
+ char *const ptr = &buf[len - 10];
|
|
|
|
+ if (strcmp(ptr, " (deleted)") == 0) {
|
|
|
|
+ *ptr = '\0';
|
|
|
|
+ curr = &buf[0];
|
|
|
|
+ break; /* Path is deleted from VFS cache */
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (buf[0] != '/') {
|
|
|
|
+ const char *slash;
|
|
|
|
+
|
|
|
|
+ if ((slash = strrchr(prev, '/'))) {
|
|
|
|
+ size_t off = slash - prev + 1;
|
|
|
|
+
|
|
|
|
+ if (off + len > PATH_MAX)
|
|
|
|
+ len = PATH_MAX - off;
|
|
|
|
+
|
|
|
|
+ memmove(&buf[off], &buf[0], len + 1);
|
|
|
|
+ memcpy(&buf[0], prev, off);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ curr = &buf[0];
|
|
|
|
+
|
|
|
|
+ if (deep-- <= 0) return 0;
|
|
|
|
+
|
|
|
|
+ } while (1);
|
|
|
|
+
|
|
|
|
+ if (real) strcpy(real, curr);
|
|
|
|
+
|
|
|
|
+ if (errno == EINVAL) {
|
2009-03-11 16:44:05 +01:00
|
|
|
+ const size_t nlen = strlen(curr);
|
2009-04-02 17:29:10 +02:00
|
|
|
+ struct nfs_points *p;
|
|
|
|
+ for (p = mnts; p; p = p->next) {
|
2009-03-11 16:44:05 +01:00
|
|
|
+ if (nlen < p->nlen)
|
|
|
|
+ continue;
|
|
|
|
+ if (curr[p->nlen] != '\0' && curr[p->nlen] != '/')
|
|
|
|
+ continue;
|
2009-04-02 17:29:10 +02:00
|
|
|
+ if (!strncmp(curr, p->name, p->nlen)) {
|
|
|
|
+ if (shadow(p->shadow, curr, nlen))
|
|
|
|
+ continue;
|
2007-04-26 15:51:55 +02:00
|
|
|
+ return 1;
|
2009-04-02 17:29:10 +02:00
|
|
|
+ }
|
2007-04-26 15:51:55 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
opt_type opts;
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -676,6 +895,7 @@ int main(int argc, char *argv[])
|
2008-09-24 17:25:01 +02:00
|
|
|
int optc;
|
|
|
|
char *option;
|
|
|
|
char *nsptr;
|
|
|
|
+ size_t len;
|
2007-04-26 15:51:55 +02:00
|
|
|
|
|
|
|
#ifdef WITH_IPV6
|
2008-09-24 17:25:01 +02:00
|
|
|
ipv4_only = ipv6_only = 0;
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -692,7 +912,6 @@ int main(int argc, char *argv[])
|
2007-12-19 22:14:01 +01:00
|
|
|
#endif
|
2007-04-26 15:51:55 +02:00
|
|
|
|
2008-09-24 17:25:01 +02:00
|
|
|
netdev = find_net_dev();
|
2007-04-26 15:51:55 +02:00
|
|
|
- scan_mount_devices(opts, &mount_devices);
|
2008-09-24 17:25:01 +02:00
|
|
|
fill_unix_cache(&unixsockets);
|
|
|
|
|
2007-04-26 15:51:55 +02:00
|
|
|
/* getopt doesnt like things like -SIGBLAH */
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -782,6 +1001,10 @@ int main(int argc, char *argv[])
|
2007-04-26 15:51:55 +02:00
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
+
|
2008-09-24 17:25:01 +02:00
|
|
|
+ if (!mount_devices)
|
|
|
|
+ scan_mount_devices(opts, &mount_devices);
|
2007-04-26 15:51:55 +02:00
|
|
|
+
|
|
|
|
/* File specifications */
|
|
|
|
if ( (this_name = malloc(sizeof(struct names))) == NULL)
|
|
|
|
continue;
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -828,10 +1051,14 @@ int main(int argc, char *argv[])
|
2007-04-26 15:51:55 +02:00
|
|
|
break;
|
|
|
|
default: /* FILE */
|
|
|
|
this_name->filename = strdup(argv[optc]);
|
|
|
|
- parse_file(this_name, &match_inodes);
|
|
|
|
- parse_unixsockets(this_name, &match_inodes, unixsockets);
|
2008-09-24 17:25:01 +02:00
|
|
|
- if (opts & OPT_MOUNTPOINT || opts & OPT_MOUNTS)
|
|
|
|
+ len = strlen(this_name->filename);
|
2009-03-17 16:48:56 +01:00
|
|
|
+ if (len > 1 && this_name->filename[len-1] == '/')
|
2008-09-24 17:25:01 +02:00
|
|
|
+ this_name->filename[len-1] = '\0';
|
2007-04-26 15:51:55 +02:00
|
|
|
+ parse_file(this_name, &match_inodes, opts);
|
|
|
|
+ parse_unixsockets(this_name, &match_inodes, unixsockets, netdev, opts);
|
2008-09-24 17:25:01 +02:00
|
|
|
+ if (opts & (OPT_MOUNTPOINT | OPT_MOUNTS)) {
|
2007-04-26 15:51:55 +02:00
|
|
|
parse_mounts(this_name, mount_devices, &match_devices, opts);
|
2008-09-24 17:25:01 +02:00
|
|
|
+ }
|
2007-04-26 15:51:55 +02:00
|
|
|
break;
|
2008-09-24 17:25:01 +02:00
|
|
|
}
|
|
|
|
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -872,10 +1099,11 @@ int main(int argc, char *argv[])
|
2007-04-26 15:51:55 +02:00
|
|
|
#ifdef DEBUG
|
2008-09-24 17:25:01 +02:00
|
|
|
debug_match_lists(names_head, match_inodes, match_devices);
|
2007-04-26 15:51:55 +02:00
|
|
|
#endif
|
2009-05-15 21:46:50 +02:00
|
|
|
- scan_procs(names_head, match_inodes, match_devices, unixsockets, netdev);
|
|
|
|
+ scan_procs(opts, names_head, match_inodes, match_devices, unixsockets, netdev);
|
2007-04-26 15:51:55 +02:00
|
|
|
#ifdef NFS_CHECKS
|
|
|
|
scan_knfsd(names_head, match_devices);
|
|
|
|
#endif /* NFS_CHECKS */
|
2009-04-02 17:29:10 +02:00
|
|
|
+ clear_mnt();
|
|
|
|
return print_matches(names_head,opts, sig_number);
|
|
|
|
}
|
|
|
|
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -978,7 +1206,7 @@ static int print_matches(struct names *n
|
2007-04-26 15:51:55 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
-static struct stat *get_pidstat(const pid_t pid, const char *filename)
|
|
|
|
+static struct stat *get_pidstat(const opt_type opts, const pid_t pid, const char *filename, char *real)
|
|
|
|
{
|
|
|
|
char pathname[256];
|
|
|
|
struct stat *st;
|
2009-05-15 21:46:50 +02:00
|
|
|
@@ -986,6 +1214,10 @@ static struct stat *get_pidstat(const pi
|
2007-04-26 15:51:55 +02:00
|
|
|
if ( (st = malloc(sizeof(struct stat))) == NULL)
|
|
|
|
return NULL;
|
|
|
|
snprintf(pathname, 256, "/proc/%d/%s", pid, filename);
|
|
|
|
+ if (check4nfs(pathname, real)) {
|
|
|
|
+ if ((opts & (OPT_MOUNTPOINT|OPT_MOUNTS)) == 0)
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
if (stat(pathname, st) != 0)
|
|
|
|
return NULL;
|
|
|
|
else
|
2009-10-12 16:47:10 +02:00
|
|
|
@@ -1030,6 +1262,8 @@ static void check_dir(const pid_t pid, c
|
2009-05-15 21:46:50 +02:00
|
|
|
}
|
|
|
|
}
|
2007-12-19 22:14:01 +01:00
|
|
|
for (dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next) {
|
2009-10-12 16:47:10 +02:00
|
|
|
+ if (dev_tmp->name->name_space & NAMESPACE_NFS)
|
2007-12-19 22:14:01 +01:00
|
|
|
+ continue;
|
|
|
|
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);
|
2009-10-12 16:47:10 +02:00
|
|
|
@@ -1039,6 +1273,8 @@ static void check_dir(const pid_t pid, c
|
2007-12-19 22:14:01 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (ino_tmp = ino_head ; ino_tmp != NULL ; ino_tmp = ino_tmp->next) {
|
2009-10-12 16:47:10 +02:00
|
|
|
+ if (ino_tmp->name->name_space & NAMESPACE_NFS)
|
2007-12-19 22:14:01 +01:00
|
|
|
+ continue;
|
|
|
|
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);
|
2009-10-12 16:47:10 +02:00
|
|
|
@@ -1050,6 +1286,8 @@ static void check_dir(const pid_t pid, c
|
2008-08-08 02:14:10 +02:00
|
|
|
}
|
|
|
|
} /* while fd_dent */
|
|
|
|
closedir(dirp);
|
|
|
|
+ free(dirpath);
|
|
|
|
+ free(filepath);
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
2009-10-12 16:47:10 +02:00
|
|
|
@@ -1070,12 +1308,18 @@ static void check_map(const pid_t pid, c
|
2007-12-19 22:14:01 +01:00
|
|
|
if (sscanf(line, "%*s %*s %*s %x:%x %lld",
|
|
|
|
&tmp_maj, &tmp_min, &tmp_inode) == 3) {
|
|
|
|
tmp_device = tmp_maj * 256 + tmp_min;
|
|
|
|
- for(dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next)
|
|
|
|
+ for(dev_tmp = dev_head ; dev_tmp != NULL ; dev_tmp = dev_tmp->next) {
|
2009-10-12 16:47:10 +02:00
|
|
|
+ if (dev_tmp->name->name_space & NAMESPACE_NFS)
|
2007-12-19 22:14:01 +01:00
|
|
|
+ continue;
|
|
|
|
if (dev_tmp->device == tmp_device)
|
|
|
|
add_matched_proc(dev_tmp->name, pid, uid, access);
|
|
|
|
- for(ino_tmp = ino_head ; ino_tmp != NULL ; ino_tmp = ino_tmp->next)
|
|
|
|
+ }
|
|
|
|
+ for(ino_tmp = ino_head ; ino_tmp != NULL ; ino_tmp = ino_tmp->next) {
|
2009-10-12 16:47:10 +02:00
|
|
|
+ if (ino_tmp->name->name_space & NAMESPACE_NFS)
|
2007-12-19 22:14:01 +01:00
|
|
|
+ continue;
|
|
|
|
if (ino_tmp->device == tmp_device && ino_tmp->inode == tmp_inode)
|
|
|
|
add_matched_proc(ino_tmp->name, pid, uid, access);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fclose(fp);
|
2009-10-12 16:47:10 +02:00
|
|
|
@@ -1146,6 +1390,16 @@ void fill_unix_cache(struct unixsocket_l
|
2008-10-06 18:08:43 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
+static inline int isnetfs(const char * type)
|
|
|
|
+{
|
|
|
|
+ static const char* netfs[] = {"nfs", "nfs4", "smbfs", "cifs", "afs", "ncpfs", (char*)0};
|
|
|
|
+ int n;
|
|
|
|
+ for (n = 0; netfs[n]; n++)
|
|
|
|
+ if (!strcasecmp(netfs[n], type))
|
|
|
|
+ return 1;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
/*
|
|
|
|
* scan_mount_devices : Create a list of mount points and devices
|
|
|
|
* This list is used later for matching purposes
|
2009-10-12 16:47:10 +02:00
|
|
|
@@ -1155,17 +1409,94 @@ void scan_mount_devices(const opt_type o
|
2007-04-26 15:51:55 +02:00
|
|
|
FILE *mntfp;
|
|
|
|
struct mntent *mnt_ptr;
|
|
|
|
struct stat st;
|
2008-08-08 02:14:10 +02:00
|
|
|
-
|
|
|
|
- if ( (mntfp = setmntent("/etc/mtab","r")) == NULL) {
|
2009-04-02 17:29:10 +02:00
|
|
|
+ const char * mtab;
|
2008-08-08 02:14:10 +02:00
|
|
|
+
|
|
|
|
+ if (stat("/proc/version", &st) < 0)
|
2009-04-02 17:29:10 +02:00
|
|
|
+ mtab = "/etc/mtab";
|
2008-08-08 02:14:10 +02:00
|
|
|
+ else
|
2009-04-02 17:29:10 +02:00
|
|
|
+ mtab = "/proc/mounts";
|
|
|
|
+
|
|
|
|
+ if ( (mntfp = setmntent(mtab,"r")) == NULL) {
|
|
|
|
fprintf(stderr, _("Cannot open /etc/mtab: %s\n"),
|
|
|
|
strerror(errno));
|
2007-04-26 15:51:55 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
while ( (mnt_ptr = getmntent(mntfp)) != NULL) {
|
2008-10-06 18:08:43 +02:00
|
|
|
+ if (isnetfs(mnt_ptr->mnt_type)) {
|
2008-08-08 02:14:10 +02:00
|
|
|
+ /*
|
2008-09-24 17:25:01 +02:00
|
|
|
+ * Remember all NFS typed partitions, required to make check4nfs() work.
|
2008-08-08 02:14:10 +02:00
|
|
|
+ */
|
2009-04-02 17:29:10 +02:00
|
|
|
+ size_t nlen = strlen(mnt_ptr->mnt_dir);
|
|
|
|
+ struct nfs_points *restrict p;
|
|
|
|
+ if (posix_memalign((void*)&p, sizeof(void*), alignof(struct nfs_points)+(nlen+1)) != 0)
|
2008-08-08 02:14:10 +02:00
|
|
|
+ goto out;
|
2009-04-02 17:29:10 +02:00
|
|
|
+ p->name = ((char*)p)+alignof(struct nfs_points);
|
|
|
|
+ p->nlen = nlen;
|
|
|
|
+ p->shadow = (struct shadow_list*)0;
|
|
|
|
+
|
|
|
|
+ strcpy(p->name, mnt_ptr->mnt_dir);
|
2008-08-08 02:14:10 +02:00
|
|
|
+ if (mnts)
|
|
|
|
+ mnts->prev = p;
|
|
|
|
+ p->next = mnts;
|
|
|
|
+ p->prev = (struct nfs_points*)0;
|
|
|
|
+ mnts = p;
|
2007-04-26 15:51:55 +02:00
|
|
|
+ if ((opts & (OPT_MOUNTPOINT|OPT_MOUNTS)) == 0) {
|
2008-08-08 02:14:10 +02:00
|
|
|
+ add_mount_device(mount_devices, mnt_ptr->mnt_fsname, mnt_ptr->mnt_dir, (dev_t)-1);
|
2007-04-26 15:51:55 +02:00
|
|
|
+ continue;
|
|
|
|
+ }
|
2008-09-24 17:25:01 +02:00
|
|
|
+ if (nfssafe(stat, mnt_ptr->mnt_dir, &st) == 0) {
|
|
|
|
+ add_mount_device(mount_devices, mnt_ptr->mnt_fsname, mnt_ptr->mnt_dir, st.st_dev);
|
|
|
|
+ } else {
|
|
|
|
+ fprintf(stderr, _("Cannot stat file %s: %s\n"), mnt_ptr->mnt_dir, strerror(errno));
|
|
|
|
+ }
|
|
|
|
+ continue;
|
2007-04-26 15:51:55 +02:00
|
|
|
+ }
|
2008-09-24 17:25:01 +02:00
|
|
|
+ if ((opts & (OPT_MOUNTPOINT|OPT_MOUNTS)) == 0)
|
|
|
|
+ continue;
|
2007-04-26 15:51:55 +02:00
|
|
|
if (stat(mnt_ptr->mnt_dir, &st) == 0) {
|
|
|
|
add_mount_device(mount_devices, mnt_ptr->mnt_fsname, mnt_ptr->mnt_dir, st.st_dev);
|
2008-09-24 17:25:01 +02:00
|
|
|
+ } else {
|
|
|
|
+ fprintf(stderr, _("Cannot stat file %s: %s\n"), mnt_ptr->mnt_dir, strerror(errno));
|
2009-10-12 16:47:10 +02:00
|
|
|
+ }
|
|
|
|
+ }
|
2009-04-02 17:29:10 +02:00
|
|
|
+ endmntent(mntfp);
|
|
|
|
+
|
|
|
|
+ if (!mnts)
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ if ((mntfp = setmntent("/proc/mounts", "r")) == NULL) {
|
|
|
|
+ fprintf(stderr, _("Cannot open /etc/mtab: %s\n"), strerror(errno));
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ while ((mnt_ptr = getmntent(mntfp)) != NULL) {
|
|
|
|
+ struct nfs_points *p;
|
|
|
|
+
|
|
|
|
+ for (p = mnts; p; p = p->next) {
|
|
|
|
+ struct shadow_list *s;
|
|
|
|
+ size_t nlen;
|
|
|
|
+
|
|
|
|
+ if (strcmp(mnt_ptr->mnt_dir, p->name) == 0)
|
|
|
|
+ continue;
|
|
|
|
+ if (strncmp(mnt_ptr->mnt_dir, p->name, p->nlen) != 0)
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ nlen = strlen(mnt_ptr->mnt_dir);
|
|
|
|
+ if (posix_memalign((void*)&s, sizeof(void*), alignof(struct shadow_list)+(nlen+1)) != 0)
|
|
|
|
+ goto out;
|
|
|
|
+ s->name = ((char*)s)+alignof(struct shadow_list);
|
|
|
|
+ s->nlen = nlen;
|
|
|
|
+
|
|
|
|
+ strcpy(s->name, mnt_ptr->mnt_dir);
|
|
|
|
+ if (p->shadow)
|
|
|
|
+ p->shadow->prev = s;
|
|
|
|
+ s->next = p->shadow;
|
|
|
|
+ s->prev = (struct shadow_list*)0;
|
|
|
|
+ p->shadow = s;
|
2009-10-12 16:47:10 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-08 02:14:10 +02:00
|
|
|
+out:
|
2007-04-26 15:51:55 +02:00
|
|
|
+ endmntent(mntfp);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
2009-10-12 16:47:10 +02:00
|
|
|
@@ -1291,3 +1622,56 @@ static void scan_knfsd(struct names *nam
|
2008-09-24 17:25:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* NFSCHECKS */
|
|
|
|
+
|
|
|
|
+static sigjmp_buf jenv;
|
|
|
|
+static int timeout = 5;
|
|
|
|
+static void sigalarm(int sig)
|
|
|
|
+{
|
|
|
|
+ if (sig == SIGALRM)
|
|
|
|
+ siglongjmp(jenv, 1);
|
|
|
|
+}
|
|
|
|
+static int nfssafe(stat_t func, const char *path, struct stat *buf)
|
|
|
|
+{
|
|
|
|
+ pid_t pid = 0;
|
|
|
|
+ int ret = 0, pipes[4];
|
|
|
|
+
|
|
|
|
+ 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)
|
|
|
|
+ write(pipes[1], buf, sizeof(struct stat));
|
|
|
|
+ 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;
|
|
|
|
+ timeout = 1;
|
|
|
|
+ goto err;
|
|
|
|
+ }
|
|
|
|
+ (void) signal(SIGALRM, sigalarm);
|
|
|
|
+ (void) alarm(timeout);
|
|
|
|
+ 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;
|
|
|
|
+}
|
2007-12-19 22:14:01 +01:00
|
|
|
--- src/fuser.h
|
2009-05-15 21:46:50 +02:00
|
|
|
+++ src/fuser.h 2009-03-27 13:23:36.000000000 +0100
|
2009-04-02 17:29:10 +02:00
|
|
|
@@ -80,9 +80,33 @@ struct unixsocket_list {
|
2007-12-19 22:14:01 +01:00
|
|
|
struct unixsocket_list *next;
|
|
|
|
};
|
|
|
|
|
2009-04-02 17:29:10 +02:00
|
|
|
+struct shadow_list
|
|
|
|
+{
|
|
|
|
+ struct shadow_list *next;
|
|
|
|
+ struct shadow_list *prev;
|
|
|
|
+ size_t nlen;
|
|
|
|
+ char * name;
|
|
|
|
+};
|
|
|
|
+
|
2007-12-19 22:14:01 +01:00
|
|
|
+struct nfs_points {
|
|
|
|
+ struct nfs_points *next, *prev;
|
2009-04-02 17:29:10 +02:00
|
|
|
+ struct shadow_list *shadow;
|
2007-12-19 22:14:01 +01:00
|
|
|
+ size_t nlen;
|
2009-04-02 17:29:10 +02:00
|
|
|
+ char * name;
|
2007-12-19 22:14:01 +01:00
|
|
|
+};
|
2009-04-02 17:29:10 +02:00
|
|
|
+
|
|
|
|
+#if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
|
|
|
|
+# ifndef restrict
|
|
|
|
+# define restrict __restrict__
|
|
|
|
+# endif
|
|
|
|
+#endif
|
|
|
|
+#define alignof(type) ((sizeof(type)+(sizeof(void*)-1)) & ~(sizeof(void*)-1))
|
|
|
|
+
|
2007-12-19 22:14:01 +01:00
|
|
|
+
|
|
|
|
#define NAMESPACE_FILE 0
|
|
|
|
#define NAMESPACE_TCP 1
|
|
|
|
#define NAMESPACE_UDP 2
|
|
|
|
+#define NAMESPACE_NFS 4
|
|
|
|
|
|
|
|
#define MAX_PATHNAME 200
|
|
|
|
#define MAX_CMDNAME 16
|