From ad506a98d82194fd632409b687a0d7fd61a1eb4c Mon Sep 17 00:00:00 2001 From: Stefan Siegl Date: Mon, 30 Jan 2006 22:37:59 +0000 Subject: moved headers into new include/ directory, sources moved into new src/ directory. --- src/node.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/node.c (limited to 'src/node.c') diff --git a/src/node.c b/src/node.c new file mode 100644 index 000000000..a09cc5c6b --- /dev/null +++ b/src/node.c @@ -0,0 +1,69 @@ +/********************************************************** + * node.c + * + * Copyright(C) 2004, 2005 by Stefan Siegl , Germany + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Publice License, + * version 2 or any later. The license is contained in the COPYING + * file that comes with the libfuse distribution. + * + * create (and care for) nodes ... + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include + +#include "fuse_i.h" +#include "fuse.h" + +/* create a new node for the specified netnode + */ +struct node * +fuse_make_node(struct netnode *nn) +{ + struct node *node; + + DEBUG("fuse_make_node", "creating node for %s.\n", nn->path); + DEBUG("netnode-lock", "locking netnode, path=%s\n", nn->path); + mutex_lock(&nn->lock); + + if((node = nn->node)) + { + /* there already is a node, therefore return another reference to it */ + netfs_nref(node); + mutex_unlock(&nn->lock); + DEBUG("netnode-lock", "UNlocking netnode, path=%s\n", nn->path); + DEBUG("fuse_make_node", "reusing already existing node, %s\n", nn->path); + return node; + } + + if(! (node = netfs_make_node(nn))) + { + mutex_unlock(&nn->lock); + DEBUG("netnode-lock", "UNlocking netnode, path=%s\n", nn->path); + return NULL; /* doesn't look to good for us :-( */ + } + + /* now initialize those stats for which we are reliable ... + */ + node->nn_stat.st_ino = nn->inode; + node->nn_stat.st_blksize = 4096; /* depends on our host program, but since + * we're expected to fill, assume 4k for now + */ + node->nn_stat.st_rdev = 0; + + /* add pointer to our new node structure to the netnode */ + nn->node = node; + + mutex_unlock(&nn->lock); + DEBUG("netnode-lock", "UNlocking netnode, path=%s\n", nn->path); + DEBUG("fuse_make_node", "created a new node for %s.\n", nn->path); + return node; +} -- cgit v1.2.3