[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
libfuse/src fuse_i.h main.c netfs.c
From: |
Stefan Siegl |
Subject: |
libfuse/src fuse_i.h main.c netfs.c |
Date: |
Fri, 04 Aug 2006 00:39:39 +0000 |
CVSROOT: /sources/hurdextras
Module name: libfuse
Changes by: Stefan Siegl <stesie> 06/08/04 00:39:38
Modified files:
src : fuse_i.h main.c netfs.c
Log message:
added support for fuse contexts, including fuse_get_context function
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libfuse/src/fuse_i.h?cvsroot=hurdextras&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/libfuse/src/main.c?cvsroot=hurdextras&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/libfuse/src/netfs.c?cvsroot=hurdextras&r1=1.3&r2=1.4
Patches:
Index: fuse_i.h
===================================================================
RCS file: /sources/hurdextras/libfuse/src/fuse_i.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- fuse_i.h 13 Apr 2006 22:52:47 -0000 1.2
+++ fuse_i.h 4 Aug 2006 00:39:36 -0000 1.3
@@ -1,7 +1,7 @@
/**********************************************************
* fuse_i.h
*
- * Copyright (C) 2004, 2005 by Stefan Siegl <address@hidden>, Germany
+ * Copyright (C) 2004, 2005, 2006 by Stefan Siegl <address@hidden>, Germany
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Publice License,
@@ -131,6 +131,12 @@
extern struct _libfuse_params libfuse_params;
+/* the private data pointer returned from init() callback */
+extern void *fsys_privdata;
+
+/* magic number, passed from fuse_mount to fuse_new */
+#define FUSE_MAGIC ((int) 0x66757365)
+
/*****************************************************************************
Index: main.c
===================================================================
RCS file: /sources/hurdextras/libfuse/src/main.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- main.c 3 Aug 2006 22:50:38 -0000 1.5
+++ main.c 4 Aug 2006 00:39:36 -0000 1.6
@@ -39,9 +39,8 @@
/* the port where to write out debug messages to, NULL to omit these */
FILE *debug_port = NULL;
-/* magic number, passed from fuse_mount to fuse_new */
-#define FUSE_MAGIC ((int) 0x66757365)
-
+/* the private data pointer returned from init() callback */
+void *fsys_privdata = NULL;
/* Interpret a __single__ mount option
@@ -322,6 +321,9 @@
fuse_ops_compat22 = op;
+ if(op->init)
+ fsys_privdata = op->init();
+
return (void *) FUSE_MAGIC; /* we don't have a fuse structure, sorry. */
}
@@ -529,3 +531,11 @@
*/
return 0;
}
+
+
+struct fuse_context *
+fuse_get_context(void)
+{
+ struct fuse_context *ctx = cthread_data(cthread_self());
+ return ctx;
+}
Index: netfs.c
===================================================================
RCS file: /sources/hurdextras/libfuse/src/netfs.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- netfs.c 3 Aug 2006 17:45:43 -0000 1.3
+++ netfs.c 4 Aug 2006 00:39:36 -0000 1.4
@@ -1,7 +1,7 @@
/**********************************************************
* netfs.c
*
- * Copyright(C) 2004, 2005 by Stefan Siegl <address@hidden>, Germany
+ * Copyright(C) 2004,2005,2006 by Stefan Siegl <address@hidden>, Germany
*
* This is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Publice License,
@@ -50,6 +50,48 @@
char *filename;
};
+
+static inline void
+refresh_context_struct(struct iouser *cred)
+{
+ FUNC_PROLOGUE("refresh_context_struct");
+ struct fuse_context *ctx = cthread_data(cthread_self());
+
+ if(! ctx)
+ {
+ ctx = malloc(sizeof(struct fuse_context));
+ if(! ctx)
+ {
+ perror(PACKAGE_NAME);
+ return;
+ }
+
+ cthread_set_data(cthread_self(), ctx);
+
+ ctx->fuse = (void *) FUSE_MAGIC;
+ ctx->private_data = fsys_privdata;
+
+ /* FIXME, how to figure out the pid of the program asking for the
+ * filesystem operation? */
+ ctx->pid = 0;
+ }
+
+ if(cred)
+ {
+ ctx->uid = cred->uids->num ? cred->uids->ids[0] :
+ (libfuse_params.force_uid ? libfuse_params.uid : geteuid());
+ ctx->gid = cred->gids->num ? cred->gids->ids[0] :
+ (libfuse_params.force_gid ? libfuse_params.gid : getegid());
+ }
+ else
+ {
+ ctx->uid = libfuse_params.force_uid ? libfuse_params.uid : geteuid();
+ ctx->gid = libfuse_params.force_gid ? libfuse_params.gid : getegid();
+ }
+
+ FUNC_EPILOGUE_NORET();
+}
+
/* Check whether to allow access to a node, testing the allow_root and
* allow_other flag. This does not check whether default permissions
* are okay to allow access.
@@ -105,7 +147,10 @@
FUNC_RETURN(EPERM);
if(FUSE_OP_HAVE(getattr))
+ {
+ refresh_context_struct(cred);
err = -FUSE_OP_CALL(getattr, node->nn->path, &node->nn_stat);
+ }
if(! err)
{
@@ -267,7 +312,10 @@
err = EPERM;
else if(FUSE_OP_HAVE(statfs))
+ {
+ refresh_context_struct(cred);
err = -FUSE_OP_CALL(statfs, node->nn->path, st);
+ }
else
err = EOPNOTSUPP;
@@ -482,7 +530,10 @@
if(test_allow_root_or_other(cred))
err = EPERM;
else
+ {
+ refresh_context_struct(cred);
err = fuse_sync_filesystem();
+ }
FUNC_EPILOGUE(err);
}
- libfuse/src fuse_i.h main.c netfs.c,
Stefan Siegl <=