[BACK]Return to uipc_usrreq.c CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / kern

Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.

Diff for /src/sys/kern/uipc_usrreq.c between version 1.72 and 1.73

version 1.72, 2003/11/29 10:02:42 version 1.73, 2003/12/29 22:08:02
Line 974  unp_internalize(control, p)
Line 974  unp_internalize(control, p)
         struct proc *p;          struct proc *p;
 {  {
         struct filedesc *fdescp = p->p_fd;          struct filedesc *fdescp = p->p_fd;
         struct cmsghdr *cm = mtod(control, struct cmsghdr *);          struct cmsghdr *newcm, *cm = mtod(control, struct cmsghdr *);
         struct file **rp;          struct file **rp, **files;
         struct file *fp;          struct file *fp;
         int i, fd, *fdp;          int i, fd, *fdp;
         int nfds;          int nfds;
Line 997  unp_internalize(control, p)
Line 997  unp_internalize(control, p)
         }          }
   
         /* Make sure we have room for the struct file pointers */          /* Make sure we have room for the struct file pointers */
  morespace:  
         neededspace = CMSG_SPACE(nfds * sizeof(struct file *)) -          neededspace = CMSG_SPACE(nfds * sizeof(struct file *)) -
             control->m_len;              control->m_len;
         if (neededspace > M_TRAILINGSPACE(control)) {          if (neededspace > M_TRAILINGSPACE(control)) {
   
                 /* if we already have a cluster, the message is just too big */                  /* allocate new space and copy header into it */
                 if (control->m_flags & M_EXT)                  newcm = malloc(
                       CMSG_SPACE(nfds * sizeof(struct file *)),
                       M_MBUF, M_WAITOK);
                   if (newcm == NULL)
                         return (E2BIG);                          return (E2BIG);
                   memcpy(newcm, cm, sizeof(struct cmsghdr));
                 /* allocate a cluster and try again */                  files = (struct file **)CMSG_DATA(newcm);
                 m_clget(control, M_WAIT);          } else {
                 if ((control->m_flags & M_EXT) == 0)                  /* we can convert in-place */
                         return (ENOBUFS);       /* allocation failed */                  newcm = NULL;
                   files = (struct file **)CMSG_DATA(cm);
                 /* copy the data to the cluster */  
                 memcpy(mtod(control, char *), cm, cm->cmsg_len);  
                 cm = mtod(control, struct cmsghdr *);  
                 goto morespace;  
         }          }
   
         /* adjust message & mbuf to note amount of space actually used. */  
         cm->cmsg_len = CMSG_LEN(nfds * sizeof(struct file *));  
         control->m_len = CMSG_SPACE(nfds * sizeof(struct file *));  
   
         /*          /*
          * Transform the file descriptors into struct file pointers, in           * Transform the file descriptors into struct file pointers, in
          * reverse order so that if pointers are bigger than ints, the           * reverse order so that if pointers are bigger than ints, the
          * int won't get until we're done.           * int won't get until we're done.
          */           */
         fdp = ((int *)CMSG_DATA(cm)) + nfds - 1;          fdp = (int *)CMSG_DATA(cm) + nfds - 1;
         rp = ((struct file **)CMSG_DATA(cm)) + nfds - 1;          rp = files + nfds - 1;
         for (i = 0; i < nfds; i++) {          for (i = 0; i < nfds; i++) {
                 fp = fdescp->fd_ofiles[*fdp--];                  fp = fdescp->fd_ofiles[*fdp--];
                 simple_lock(&fp->f_slock);                  simple_lock(&fp->f_slock);
Line 1041  unp_internalize(control, p)
Line 1035  unp_internalize(control, p)
                 simple_unlock(&fp->f_slock);                  simple_unlock(&fp->f_slock);
                 unp_rights++;                  unp_rights++;
         }          }
   
           if (newcm) {
                   if (control->m_flags & M_EXT)
                           MEXTREMOVE(control);
                   MEXTADD(control, newcm,
                       CMSG_SPACE(nfds * sizeof(struct file *)),
                       M_MBUF, NULL, NULL);
                   cm = newcm;
           }
   
           /* adjust message & mbuf to note amount of space actually used. */
           cm->cmsg_len = CMSG_LEN(nfds * sizeof(struct file *));
           control->m_len = CMSG_SPACE(nfds * sizeof(struct file *));
   
         return (0);          return (0);
 }  }
   

Legend:
Removed from v.1.72  
changed lines
  Added in v.1.73

CVSweb <webmaster@jp.NetBSD.org>