summaryrefslogtreecommitdiff
path: root/ftpfs/fs.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-08-06 22:08:59 +0000
committerMiles Bader <miles@gnu.org>1997-08-06 22:08:59 +0000
commit80c437f2f35813085b86cc05987609ec36d18865 (patch)
treefdda379edf638d85d6bbf1bb9fb2934dba4cc1a6 /ftpfs/fs.c
parentf20a48afff1d935eea20aa2c02b5fd805e85663c (diff)
Initial checkin
Diffstat (limited to 'ftpfs/fs.c')
-rw-r--r--ftpfs/fs.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/ftpfs/fs.c b/ftpfs/fs.c
new file mode 100644
index 00000000..86697c62
--- /dev/null
+++ b/ftpfs/fs.c
@@ -0,0 +1,82 @@
+/* Fs operations
+
+ Copyright (C) 1997 Free Software Foundation, Inc.
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+
+#include <string.h>
+
+#include <hurd/ihash.h>
+#include <hurd/netfs.h>
+
+#include "ftpfs.h"
+
+/* Create a new ftp filesystem with the given parameters. */
+error_t
+ftpfs_create (char *rmt_path,
+ struct ftp_conn_params *ftp_params,
+ struct ftp_conn_hooks *ftp_hooks,
+ struct ftpfs_params *params,
+ struct ftpfs **fs)
+{
+ error_t err;
+ /* Since nodes keep some of their state in the enclosing directory, we need
+ one for the root node. */
+ struct ftpfs_dir *super_root_dir;
+ /* And also a super-root node, just used for locking SUPER_ROOT_DIR. */
+ struct node *super_root;
+ /* The new node. */
+ struct ftpfs *new = malloc (sizeof (struct ftpfs));
+
+ if (! new)
+ return ENOMEM;
+
+ new->free_conns = 0;
+ new->conns = 0;
+ spin_lock_init (&new->conn_lock);
+ new->node_cache_mru = new->node_cache_lru = 0;
+ new->node_cache_len = 0;
+ mutex_init (&new->node_cache_lock);
+
+ new->params = *params;
+ new->ftp_params = ftp_params;
+ new->ftp_hooks = ftp_hooks;
+
+ err = ihash_create (&new->inode_mappings);
+ spin_lock_init (&new->inode_mappings_lock);
+
+ if (! err)
+ {
+ super_root = netfs_make_node (0);
+ if (! super_root)
+ err = ENOMEM;
+ }
+ if (! err)
+ err = ftpfs_dir_create (new, super_root, rmt_path, &super_root_dir);
+ if (! err)
+ err = ftpfs_dir_lookup (super_root_dir, "", &new->root);
+
+ if (err)
+ free (new);
+ else
+ {
+ mutex_unlock (&new->root->lock);
+ *fs = new;
+ }
+
+ return err;
+}