/[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.8 by roland, Sat Dec 29 23:44:22 2001 UTC revision 1.9 by roland, Sun Dec 30 00:31:03 2001 UTC
# Line 231  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;
234      size_t ofs;
235    
236    /* 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
237       port number to connect to and the block size to use.  */       port number to connect to and the block size to use.  */
# Line 276  nbdopen (const char *name, int *mod_flag Line 277  nbdopen (const char *name, int *mod_flag
277    for (ap = he->h_addr_list; *ap != 0; ++ap)    for (ap = he->h_addr_list; *ap != 0; ++ap)
278      {      {
279        sin.sin_addr = *(const struct in_addr *) *ap;        sin.sin_addr = *(const struct in_addr *) *ap;
280          errno = 0;
281        if (connect (sock, &sin, sizeof sin) == 0 || errno == ECONNREFUSED)        if (connect (sock, &sin, sizeof sin) == 0 || errno == ECONNREFUSED)
282          break;          break;
283      }      }
284    if (*ap != 0)                 /* last connect failed */    if (errno != 0)               /* last connect failed */
285      {      {
286        error_t err = errno;        error_t err = errno;
287        close (sock);        close (sock);
# Line 287  nbdopen (const char *name, int *mod_flag Line 289  nbdopen (const char *name, int *mod_flag
289      }      }
290    
291    /* Read the startup packet, which tells us the size of the store.  */    /* Read the startup packet, which tells us the size of the store.  */
292      ofs = 0;
293      do {
294        cc = read (sock, (char *) &ns + ofs, sizeof ns - ofs);
295        if (cc < 0)
296          {
297            error_t err = errno;
298            close (sock);
299            return err;
300          }
301        ofs += cc;
302      } while (cc > 0 && ofs < sizeof ns);
303    
304    cc = read (sock, &ns, sizeof ns);    if (cc < sizeof ns
   if (cc < 0)  
     {  
       error_t err = errno;  
       close (sock);  
       return err;  
     }  
   if (cc != sizeof ns  
305        || memcmp (ns.magic, NBD_INIT_MAGIC, sizeof ns.magic) != 0)        || memcmp (ns.magic, NBD_INIT_MAGIC, sizeof ns.magic) != 0)
306      {      {
307        close (sock);        close (sock);

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

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