[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] Setup the node stat information in netfs_validate_stat.
From: |
Sergiu Ivanov |
Subject: |
[PATCH 2/2] Setup the node stat information in netfs_validate_stat. |
Date: |
Mon, 10 Aug 2009 23:12:42 +0300 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
>From a5fed70ec0d00b4b4a5bc51bcc15b67b56521d55 Mon Sep 17 00:00:00 2001
From: Sergiu Ivanov <unlimitedscolobb@gmail.com>
Date: Mon, 10 Aug 2009 01:25:26 +0300
Subject: [PATCH] Setup the node stat information in netfs_validate_stat.
* eth-multiplexer/device_impl.c (ds_device_open): Don't
set the stat information.
* eth-multiplexer/multiplexer.c (main): Store the stat
information in the nn_stat field of the root node.
* eth-multiplexer/netfs_impl.c (new_node): Invalidate the
stat information in the new node.
(netfs_validate_stat): Don't change the stat information of
the root node; set up the stat information for the other
nodes only if has not been set already.
* eth-multiplexer/netfs_impl.h (NODE_STAT_INVALID): New
defintion.
(netnode.flags): New field.
---
eth-multiplexer/device_impl.c | 15 ++++++---------
eth-multiplexer/multiplexer.c | 2 +-
eth-multiplexer/netfs_impl.c | 34 +++++++++++++++++++++++++++-------
eth-multiplexer/netfs_impl.h | 5 +++++
4 files changed, 39 insertions(+), 17 deletions(-)
diff --git a/eth-multiplexer/device_impl.c b/eth-multiplexer/device_impl.c
index 4b2d37d..abbd146 100644
--- a/eth-multiplexer/device_impl.c
+++ b/eth-multiplexer/device_impl.c
@@ -98,8 +98,6 @@ ds_device_open (mach_port_t master_port, mach_port_t
reply_port,
{
extern struct port_bucket *port_bucket;
extern struct port_class *vdev_portclass;
- extern struct stat underlying_node_stat;
- static int ino_count = 0;
/* Create a new light node (virtual device). */
struct lnode *ln = (struct lnode *) add_vdev (pi->po->np->nn->name,
sizeof (*ln),
@@ -110,13 +108,12 @@ ds_device_open (mach_port_t master_port, mach_port_t
reply_port,
ports_port_deref (pi);
return D_NO_MEMORY;
}
- memset (&ln->st, 0, sizeof (ln->st));
- ln->st.st_ino = ++ino_count;
- ln->st.st_mode = S_IFCHR | (underlying_node_stat.st_mode & ~S_IFMT);
- ln->st.st_ctime = ln->st.st_mtime = ln->st.st_atime = time (NULL);
- fshelp_touch (&ln->st, TOUCH_ATIME|TOUCH_MTIME|TOUCH_CTIME,
- multiplexer_maptime);
- pi->po->np->nn->ln = ln;
+
+ /* Connect the libnetfs node and the light node together. */
+ ln->n = pi->po->np;
+ ln->n->nn->ln = ln;
+
+ ln->st = ln->n->nn_stat;
}
dev = (struct vether_device *) pi->po->np->nn->ln;
diff --git a/eth-multiplexer/multiplexer.c b/eth-multiplexer/multiplexer.c
index 1d0b7ed..173a8f9 100644
--- a/eth-multiplexer/multiplexer.c
+++ b/eth-multiplexer/multiplexer.c
@@ -180,7 +180,7 @@ main (int argc, char *argv[])
stat.st_mode &= ~(S_ITRANS | S_IFMT);
stat.st_mode |= S_IFDIR;
- netfs_root_node->nn->ln->st = stat;
+ netfs_root_node->nn_stat = stat;
fshelp_touch (&netfs_root_node->nn_stat, TOUCH_ATIME|TOUCH_MTIME|TOUCH_CTIME,
multiplexer_maptime);
diff --git a/eth-multiplexer/netfs_impl.c b/eth-multiplexer/netfs_impl.c
index 40015a8..c70701b 100644
--- a/eth-multiplexer/netfs_impl.c
+++ b/eth-multiplexer/netfs_impl.c
@@ -64,6 +64,8 @@ new_node (struct lnode *ln, struct node **np)
struct netnode *nn = calloc (1, sizeof *nn);
struct node *node;
+ nn->flags = NODE_STAT_INVALID;
+
if (nn == 0)
return ENOMEM;
node = netfs_make_node (nn);
@@ -163,16 +165,34 @@ netfs_report_access (struct iouser *cred, struct node
*node, int *types)
error_t
netfs_validate_stat (struct node *node, struct iouser *cred)
{
- struct stat st;
+ debug("node: %p", node);
+
+ if (node == netfs_root_node)
+ /* The stat information about the root node has already been
+ initialized at startup. */
+ return 0;
+
+ if (node->nn->flags & NODE_STAT_INVALID)
+ {
+ /* This node has just been created. */
+
+ static int ino_count = 0;
+ io_statbuf_t * statp = &node->nn_stat;
+
+ memset (statp, 0, sizeof (io_statbuf_t));
+
+ statp->st_ino = ++ino_count;
+ statp->st_mode = S_IFCHR | (underlying_node_stat.st_mode & ~S_IFMT);
+
+ fshelp_touch (statp, TOUCH_ATIME | TOUCH_MTIME | TOUCH_CTIME,
+ multiplexer_maptime);
+
+ node->nn->flags &= ~NODE_STAT_INVALID;
+ }
if (node->nn->ln)
- st = node->nn->ln->st;
- else
- st = underlying_node_stat;
+ node->nn->ln->st = node->nn_stat;
- debug("node: %p", node);
- node->nn_translated = S_ISLNK (st.st_mode) ? S_IFLNK : 0;
- node->nn_stat = st;
return 0;
}
diff --git a/eth-multiplexer/netfs_impl.h b/eth-multiplexer/netfs_impl.h
index 17c66f6..ec3b389 100644
--- a/eth-multiplexer/netfs_impl.h
+++ b/eth-multiplexer/netfs_impl.h
@@ -26,10 +26,15 @@
#include "vdev.h"
+/* Shows the stat information in the node is invalid. */
+#define NODE_STAT_INVALID 0x0001
+
struct netnode
{
struct lnode *ln;
char *name;
+
+ int flags;
};
struct lnode
--
1.5.2.4