bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] Setup the node stat information in netfs_validate_stat.


From: Da Zheng
Subject: Re: [PATCH 2/2] Setup the node stat information in netfs_validate_stat.
Date: Tue, 22 Dec 2009 19:40:12 +0800
User-agent: Thunderbird 2.0.0.23 (Macintosh/20090812)

Hi,

Sergiu Ivanov wrote:
> 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;
> +    }
I'm not as familiar with netfs as you. Could you tell me why initializing node 
status here is perferred?

Best regards,
Zheng Da




reply via email to

[Prev in Thread] Current Thread [Next in Thread]