summaryrefslogtreecommitdiff
path: root/ftpfs
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1998-10-20 08:38:41 +0000
committerRoland McGrath <roland@gnu.org>1998-10-20 08:38:41 +0000
commitfc40a731d23f893be2cb7699d7e078568d4c210c (patch)
tree9f1c90570e03a7c4082bee3fca2ced1755ac98a0 /ftpfs
parent6b0d5d23a26adea266903f285f7424a2f93863cb (diff)
Add braces to silence gcc warnings.
Diffstat (limited to 'ftpfs')
-rw-r--r--ftpfs/ChangeLog8
-rw-r--r--ftpfs/dir.c203
-rw-r--r--ftpfs/ftpfs.c20
-rw-r--r--ftpfs/netfs.c56
4 files changed, 153 insertions, 134 deletions
diff --git a/ftpfs/ChangeLog b/ftpfs/ChangeLog
index 02640231..17e39728 100644
--- a/ftpfs/ChangeLog
+++ b/ftpfs/ChangeLog
@@ -1,3 +1,11 @@
+1998-10-20 Roland McGrath <roland@baalperazim.frob.com>
+
+ * ftpfs.c (netfs_append_args): Add braces to silence gcc warning.
+ * netfs.c (get_dirents): Likewise.
+ (netfs_get_dirents): Likewise.
+ * dir.c (ftpfs_refresh_node): Likewise.
+ (ftpfs_dir_lookup): Likewise.
+
1998-09-04 Roland McGrath <roland@baalperazim.frob.com>
* ftpfs.c (netfs_append_args): Use %ld for time_t and %Zu for size_t.
diff --git a/ftpfs/dir.c b/ftpfs/dir.c
index 2f6eda34..f083848a 100644
--- a/ftpfs/dir.c
+++ b/ftpfs/dir.c
@@ -1,6 +1,6 @@
/* Directory operations
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
This file is part of the GNU Hurd.
@@ -392,7 +392,7 @@ refresh_dir (struct ftpfs_dir *dir, int update_stats, time_t timestamp,
else
/* Just fetch names. */
err = ftp_conn_get_names (conn, dir->rmt_path, update_ordered_name, &dfs);
-
+
if (! err)
/* GC any directory entries that weren't seen this time. */
{
@@ -474,49 +474,51 @@ ftpfs_refresh_node (struct node *node)
&& entry->noent)
err = ENOENT;
else if (entry->stat_timestamp + dir->fs->params.stat_timeout < timestamp)
- /* Stat information needs updating. */
- if (need_bulk_stat (timestamp, dir))
- /* Refetch the whole directory from the server. */
- {
- err = refresh_dir (entry->dir, 1, timestamp, entry);
- if (!err && entry->noent)
- err = ENOENT;
- }
- else
- {
- struct ftp_conn *conn;
-
- err = ftpfs_get_ftp_conn (dir->fs, &conn);
-
- if (! err)
- {
- char *rmt_path;
-
- err = ftp_conn_append_name (conn, dir->rmt_path, entry->name,
- &rmt_path);
- if (! err)
- {
- struct refresh_entry_state res;
-
- res.entry = entry;
- res.timestamp = timestamp;
-
- if (! err)
- err = ftp_conn_get_stats (conn, rmt_path, 0,
- update_old_entry, &res);
-
- free (rmt_path);
- }
-
- ftpfs_release_ftp_conn (dir->fs, conn);
- }
-
- if (err == ENOENT)
- {
- entry->noent = 1; /* A negative entry. */
- entry->name_timestamp = timestamp;
- }
- }
+ {
+ /* Stat information needs updating. */
+ if (need_bulk_stat (timestamp, dir))
+ /* Refetch the whole directory from the server. */
+ {
+ err = refresh_dir (entry->dir, 1, timestamp, entry);
+ if (!err && entry->noent)
+ err = ENOENT;
+ }
+ else
+ {
+ struct ftp_conn *conn;
+
+ err = ftpfs_get_ftp_conn (dir->fs, &conn);
+
+ if (! err)
+ {
+ char *rmt_path;
+
+ err = ftp_conn_append_name (conn, dir->rmt_path, entry->name,
+ &rmt_path);
+ if (! err)
+ {
+ struct refresh_entry_state res;
+
+ res.entry = entry;
+ res.timestamp = timestamp;
+
+ if (! err)
+ err = ftp_conn_get_stats (conn, rmt_path, 0,
+ update_old_entry, &res);
+
+ free (rmt_path);
+ }
+
+ ftpfs_release_ftp_conn (dir->fs, conn);
+ }
+
+ if (err == ENOENT)
+ {
+ entry->noent = 1; /* A negative entry. */
+ entry->name_timestamp = timestamp;
+ }
+ }
+ }
if ((entry->stat.st_mtime < node->nn_stat.st_mtime
|| entry->stat.st_size != node->nn_stat.st_size)
@@ -613,7 +615,7 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
if (*name == '\0' || strcmp (name, ".") == 0)
/* Current directory -- just add an additional reference to DIR's node
- and return it. */
+ and return it. */
{
netfs_nref (dir->node);
*node = dir->node;
@@ -687,59 +689,62 @@ ftpfs_dir_lookup (struct ftpfs_dir *dir, const char *name,
}
if (! err)
- if (e && !e->noent)
- /* We've got a dir entry, get a node for it. */
- {
- /* If there's already a node, add a ref so that it doesn't go away. */
- spin_lock (&netfs_node_refcnt_lock);
- if (e->node)
- e->node->references++;
- spin_unlock (&netfs_node_refcnt_lock);
-
- if (! e->node)
- /* No node; make one and install it into E. */
- {
- if (! rmt_path)
- /* We have to cons up the absolute path. We need the
- connection just for the pathname frobbing functions. */
- {
- err = ftpfs_get_ftp_conn (dir->fs, &conn);
- if (! err)
- {
- err = ftp_conn_append_name (conn, dir->rmt_path, name,
- &rmt_path);
- ftpfs_release_ftp_conn (dir->fs, conn);
- }
- }
-
- if (! err)
- {
- err = ftpfs_create_node (e, rmt_path, &e->node);
-
- if (!err && dir->num_live_entries++ == 0)
- /* Keep a reference to dir's node corresponding to
- children. */
- {
- spin_lock (&netfs_node_refcnt_lock);
- dir->node->references++;
- spin_unlock (&netfs_node_refcnt_lock);
- }
- }
- }
-
- if (! err)
- {
- *node = e->node;
- /* We have to unlock DIR's node before locking the child node
- because the locking order is always child-parent. We know the
- child node won't go away because we already hold the
- additional reference to it. */
- mutex_unlock (&dir->node->lock);
- mutex_lock (&e->node->lock);
- }
- }
- else
- err = ENOENT;
+ {
+ if (e && !e->noent)
+ /* We've got a dir entry, get a node for it. */
+ {
+ /* If there's already a node, add a ref so that it doesn't go
+ away. */
+ spin_lock (&netfs_node_refcnt_lock);
+ if (e->node)
+ e->node->references++;
+ spin_unlock (&netfs_node_refcnt_lock);
+
+ if (! e->node)
+ /* No node; make one and install it into E. */
+ {
+ if (! rmt_path)
+ /* We have to cons up the absolute path. We need the
+ connection just for the pathname frobbing functions. */
+ {
+ err = ftpfs_get_ftp_conn (dir->fs, &conn);
+ if (! err)
+ {
+ err = ftp_conn_append_name (conn, dir->rmt_path, name,
+ &rmt_path);
+ ftpfs_release_ftp_conn (dir->fs, conn);
+ }
+ }
+
+ if (! err)
+ {
+ err = ftpfs_create_node (e, rmt_path, &e->node);
+
+ if (!err && dir->num_live_entries++ == 0)
+ /* Keep a reference to dir's node corresponding to
+ children. */
+ {
+ spin_lock (&netfs_node_refcnt_lock);
+ dir->node->references++;
+ spin_unlock (&netfs_node_refcnt_lock);
+ }
+ }
+ }
+
+ if (! err)
+ {
+ *node = e->node;
+ /* We have to unlock DIR's node before locking the child node
+ because the locking order is always child-parent. We know
+ the child node won't go away because we already hold the
+ additional reference to it. */
+ mutex_unlock (&dir->node->lock);
+ mutex_lock (&e->node->lock);
+ }
+ }
+ else
+ err = ENOENT;
+ }
if (err)
{
diff --git a/ftpfs/ftpfs.c b/ftpfs/ftpfs.c
index c3dd0d14..646f9b1b 100644
--- a/ftpfs/ftpfs.c
+++ b/ftpfs/ftpfs.c
@@ -328,15 +328,17 @@ netfs_append_args (char **argz, size_t *argz_len)
mutex_lock (&debug_lock);
if (ftpfs_ftp_hooks.cntl_debug && debug_stream)
- if (debug_stream != stderr)
- {
- char *rep;
- asprintf (&rep, "--debug=%s", debug_stream_name);
- err = argz_add (argz, argz_len, rep);
- free (rep);
- }
- else
- err = argz_add (argz, argz_len, "--debug");
+ {
+ if (debug_stream != stderr)
+ {
+ char *rep;
+ asprintf (&rep, "--debug=%s", debug_stream_name);
+ err = argz_add (argz, argz_len, rep);
+ free (rep);
+ }
+ else
+ err = argz_add (argz, argz_len, "--debug");
+ }
mutex_unlock (&debug_lock);
if (ftpfs->params.name_timeout != DEFAULT_NAME_TIMEOUT)
diff --git a/ftpfs/netfs.c b/ftpfs/netfs.c
index 6ea4f70e..02cea700 100644
--- a/ftpfs/netfs.c
+++ b/ftpfs/netfs.c
@@ -1,6 +1,6 @@
/* ftpfs interface to libnetfs
- Copyright (C) 1997 Free Software Foundation, Inc.
+ Copyright (C) 1997, 1998 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.ai.mit.edu>
This file is part of the GNU Hurd.
@@ -171,7 +171,7 @@ get_dirents (struct ftpfs_dir *dir,
if (! err)
{
char *p = *data;
- int count = 0;
+ int count = 0;
/* See how much space we need for the result. */
while ((max_entries == -1 || count < max_entries) && e)
@@ -183,18 +183,20 @@ get_dirents (struct ftpfs_dir *dir,
e->stat_timestamp ? IFTODT (e->stat.st_mode) : DT_UNKNOWN;
if ((p - *data) + sz > size)
- if (max_data_len > 0)
- break;
- else
- /* Try to grow our return buffer. */
- {
- vm_address_t extension = (vm_address_t)(*data + size);
- err = vm_allocate (mach_task_self (), &extension,
- DIRENTS_CHUNK_SIZE, 0);
- if (err)
- break;
- size += DIRENTS_CHUNK_SIZE;
- }
+ {
+ if (max_data_len > 0)
+ break;
+ else
+ /* Try to grow our return buffer. */
+ {
+ vm_address_t extension = (vm_address_t)(*data + size);
+ err = vm_allocate (mach_task_self (), &extension,
+ DIRENTS_CHUNK_SIZE, 0);
+ if (err)
+ break;
+ size += DIRENTS_CHUNK_SIZE;
+ }
+ }
hdr.d_namlen = name_len;
hdr.d_fileno = e->stat.st_ino;
@@ -241,15 +243,17 @@ netfs_get_dirents (struct iouser *cred, struct node *dir,
error_t err = ftpfs_refresh_node (dir);
if (! err)
- if (dir->nn->dir)
- {
- err = ftpfs_dir_refresh (dir->nn->dir);
- if (! err)
- err = get_dirents (dir->nn->dir, first_entry, max_entries,
- data, data_len, max_entries, data_entries);
- }
- else
- err = ENOTDIR;
+ {
+ if (dir->nn->dir)
+ {
+ err = ftpfs_dir_refresh (dir->nn->dir);
+ if (! err)
+ err = get_dirents (dir->nn->dir, first_entry, max_entries,
+ data, data_len, max_entries, data_entries);
+ }
+ else
+ err = ENOTDIR;
+ }
return err;
}
@@ -258,7 +262,7 @@ netfs_get_dirents (struct iouser *cred, struct node *dir,
the name was not found, then return ENOENT. On any error, clear *NODE.
(*NODE, if found, should be locked, this call should unlock DIR no matter
what.) */
-error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
+error_t netfs_attempt_lookup (struct iouser *user, struct node *dir,
char *name, struct node **node)
{
error_t err = ftpfs_refresh_node (dir);
@@ -276,7 +280,7 @@ error_t netfs_attempt_unlink (struct iouser *user, struct node *dir,
/* Note that in this one call, neither of the specific nodes are locked. */
error_t netfs_attempt_rename (struct iouser *user, struct node *fromdir,
- char *fromname, struct node *todir,
+ char *fromname, struct node *todir,
char *toname, int excl)
{
return EROFS;
@@ -291,7 +295,7 @@ error_t netfs_attempt_mkdir (struct iouser *user, struct node *dir,
}
/* Attempt to remove directory named NAME in DIR for USER. */
-error_t netfs_attempt_rmdir (struct iouser *user,
+error_t netfs_attempt_rmdir (struct iouser *user,
struct node *dir, char *name)
{
return EROFS;