/[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.13 by roland, Mon Dec 31 07:24:30 2001 UTC revision 1.14 by roland, Mon Dec 31 08:00:17 2001 UTC
# Line 288  nbd_open (const char *name, int flags, Line 288  nbd_open (const char *name, int flags,
288    return store_nbd_open (name, flags, store);    return store_nbd_open (name, flags, store);
289  }  }
290    
291  /* Valid name syntax is HOSTNAME:PORT[/BLOCKSIZE].  static const char url_prefix[] = "nbd://";
292    
293    /* Valid name syntax is [nbd://]HOSTNAME:PORT[/BLOCKSIZE].
294     If "/BLOCKSIZE" is omitted, the block size is 1.  */     If "/BLOCKSIZE" is omitted, the block size is 1.  */
295  static error_t  static error_t
296  nbd_validate_name (const char *name,  nbd_validate_name (const char *name,
297                     const struct store_class *const *classes)                     const struct store_class *const *classes)
298  {  {
299    char *p = strchr (name, ':'), *endp;    char *p, *endp;
300    
301      if (!strncmp (name, url_prefix, sizeof url_prefix - 1))
302        name += sizeof url_prefix - 1;
303    
304      p = strchr (name, ':');
305    if (p == 0)    if (p == 0)
306      return EINVAL;      return EINVAL;
307    endp = 0;    endp = 0;
# Line 329  nbdopen (const char *name, int *mod_flag Line 336  nbdopen (const char *name, int *mod_flag
336    struct nbd_startup ns;    struct nbd_startup ns;
337    ssize_t cc;    ssize_t cc;
338    size_t ofs;    size_t ofs;
339      unsigned long int port;
340      char *hostname, *p, *endp;
341    
342      if (!strncmp (name, url_prefix, sizeof url_prefix - 1))
343        name += sizeof url_prefix - 1;
344    
345    /* 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
346       port number to connect to and the block size to use.  */       port number to connect to and the block size to use.  */
347    
348    unsigned long int port;    hostname = strdupa (name);
349    char *hostname = strdupa (name);    p = strchr (hostname, ':');
   char *p = strchr (hostname, ':'), *endp;  
350    
351    if (p == 0)    if (p == 0)
352      return EINVAL;      return EINVAL;
# Line 460  nbd_clear_flags (struct store *store, in Line 471  nbd_clear_flags (struct store *store, in
471    return err;    return err;
472  }  }
473    
474  const struct store_class  const struct store_class store_nbd_class =
 store_nbd_class =  
475  {  {
476    STORAGE_NETWORK, "nbd",    STORAGE_NETWORK, "nbd",
477    open: nbd_open,    open: nbd_open,

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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