/[hurd]/hurd/libstore/nbd.c
ViewVC logotype

Diff of /hurd/libstore/nbd.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by roland, Sun Dec 23 07:34:55 2001 UTC revision 1.8 by roland, Sat Dec 29 23:44:22 2001 UTC
# Line 191  nbd_open (const char *name, int flags, Line 191  nbd_open (const char *name, int flags,
191    return store_nbd_open (name, flags, store);    return store_nbd_open (name, flags, store);
192  }  }
193    
194  static const char url_prefix[] = "nbd://";  /* Valid name syntax is HOSTNAME:PORT[/BLOCKSIZE].
   
 /* Valid name syntax is [nbd://]HOSTNAME:PORT[/BLOCKSIZE].  
195     If "/BLOCKSIZE" is omitted, the block size is 1.  */     If "/BLOCKSIZE" is omitted, the block size is 1.  */
196  static error_t  static error_t
197  nbd_validate_name (const char *name,  nbd_validate_name (const char *name,
198                     const struct store_class *const *classes)                     const struct store_class *const *classes)
199  {  {
200    char *p, *endp;    char *p = strchr (name, ':'), *endp;
   
   if (!strncmp (name, url_prefix, sizeof url_prefix - 1))  
     name += sizeof url_prefix - 1;  
   
   p = strchr (name, ':');  
201    if (p == 0)    if (p == 0)
202      return EINVAL;      return EINVAL;
203    endp = 0;    endp = 0;
204    strtoul (p, &endp, 0);    strtoul (++p, &endp, 0);
205    if (endp == 0 || endp == p)    if (endp == 0 || endp == p)
206      return EINVAL;      return EINVAL;
207    switch (*endp)    switch (*endp)
# Line 238  nbdopen (const char *name, int *mod_flag Line 231  nbdopen (const char *name, int *mod_flag
231    char **ap;    char **ap;
232    struct nbd_startup ns;    struct nbd_startup ns;
233    ssize_t cc;    ssize_t cc;
   unsigned long int port;  
   char *hostname, *p, *endp;  
   
   if (!strncmp (name, url_prefix, sizeof url_prefix - 1))  
     name += sizeof url_prefix - 1;  
234    
235    /* First we have to parse the store name to get the host name and TCP    /* First we have to parse the store name to get the host name and TCP
236       port number to connect to and the block size to use.  */       port number to connect to and the block size to use.  */
237    
238    hostname = strdupa (name);    unsigned long int port;
239    p = strchr (hostname, ':');    char *hostname = strdupa (name);
240      char *p = strchr (hostname, ':'), *endp;
241    
242    if (p == 0)    if (p == 0)
243      return EINVAL;      return EINVAL;
# Line 368  nbd_clear_flags (struct store *store, in Line 357  nbd_clear_flags (struct store *store, in
357    return err;    return err;
358  }  }
359    
360  const struct store_class store_nbd_class =  const struct store_class
361    store_nbd_class =
362  {  {
363    STORAGE_NETWORK, "nbd",    STORAGE_NETWORK, "nbd",
364    open: nbd_open,    open: nbd_open,

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26