[BACK]Return to vfs_lookup.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/vfs_lookup.c between version 1.62 and 1.63

version 1.62, 2005/06/23 17:00:30 version 1.63, 2005/07/06 18:53:00
Line 82  struct pool_cache pnbuf_cache; /* pathna
Line 82  struct pool_cache pnbuf_cache; /* pathna
  * replacement strings (and replacement string lengths) made   * replacement strings (and replacement string lengths) made
  * that impractical.   * that impractical.
  */   */
   #define VNL(x)                                                  \
           (sizeof(x) - 1)
   
   #define VO      '{'
   #define VC      '}'
   
 #define MATCH(str)                                              \  #define MATCH(str)                                              \
                 ((i + (sizeof(str) - 1) == *len) ||             \          ((termchar == '/' && i + VNL(str) == *len) ||           \
                     ((i + (sizeof(str) - 1) < *len) &&          \           (i + VNL(str) < *len &&                                \
                       (cp[i + sizeof(str) - 1] == '/'))) &&     \            cp[i + VNL(str)] == termchar)) &&                     \
                 !strncmp((str), &cp[i], sizeof(str) - 1)          !strncmp((str), &cp[i], VNL(str))
   
 #define SUBSTITUTE(m, s, sl)                                    \  #define SUBSTITUTE(m, s, sl)                                    \
                 if ((newlen + (sl)) > MAXPATHLEN)               \          if ((newlen + (sl)) > MAXPATHLEN)                       \
                         return (1);                             \                  return (1);                                     \
                 i += sizeof(m) - 1;                             \          i += VNL(m);                                            \
                 memcpy(&tmp[newlen], (s), (sl));                \          if (termchar != '/')                                    \
                 newlen += (sl);                                 \                  i++;                                            \
                 change = 1;          memcpy(&tmp[newlen], (s), (sl));                        \
           newlen += (sl);                                         \
           change = 1;                                             \
           termchar = '/';
   
 static int  static int
 symlink_magic(char *cp, int *len)  symlink_magic(struct proc *p, char *cp, int *len)
 {  {
         char tmp[MAXPATHLEN];          char tmp[MAXPATHLEN];
         int change, i, newlen;          int change, i, newlen;
           int termchar = '/';
   
         for (change = i = newlen = 0; i < *len; ) {          for (change = i = newlen = 0; i < *len; ) {
                 if (cp[i] != '@')                  if (cp[i] != '@') {
                         tmp[newlen++] = cp[i++];                          tmp[newlen++] = cp[i++];
                 else {                          continue;
                   }
   
                   i++;
   
                   /* Check for @{var} syntax. */
                   if (cp[i] == VO) {
                           termchar = VC;
                         i++;                          i++;
                         /*                  }
                          * The following checks should be ordered according  
                          * to frequency of use.                  /*
                          */                   * The following checks should be ordered according
                         if (MATCH("machine_arch")) {                   * to frequency of use.
                                 SUBSTITUTE("machine_arch", MACHINE_ARCH,                   */
                                     sizeof(MACHINE_ARCH) - 1);                  if (MATCH("machine_arch")) {
                         } else if (MATCH("machine")) {                          SUBSTITUTE("machine_arch", MACHINE_ARCH,
                                 SUBSTITUTE("machine", MACHINE,                              sizeof(MACHINE_ARCH) - 1);
                                     sizeof(MACHINE) - 1);                  } else if (MATCH("machine")) {
                         } else if (MATCH("hostname")) {                          SUBSTITUTE("machine", MACHINE,
                                 SUBSTITUTE("hostname", hostname,                              sizeof(MACHINE) - 1);
                                     hostnamelen);                  } else if (MATCH("hostname")) {
                         } else if (MATCH("osrelease")) {                          SUBSTITUTE("hostname", hostname,
                                 SUBSTITUTE("osrelease", osrelease,                              hostnamelen);
                                     strlen(osrelease));                  } else if (MATCH("osrelease")) {
                         } else if (MATCH("kernel_ident")) {                          SUBSTITUTE("osrelease", osrelease,
                                 SUBSTITUTE("kernel_ident", kernel_ident,                              strlen(osrelease));
                                     strlen(kernel_ident));                  } else if (MATCH("emul")) {
                         } else if (MATCH("domainname")) {                          SUBSTITUTE("emul", p->p_emul->e_name,
                                 SUBSTITUTE("domainname", domainname,                              strlen(p->p_emul->e_name));
                                     domainnamelen);                  } else if (MATCH("kernel_ident")) {
                         } else if (MATCH("ostype")) {                          SUBSTITUTE("kernel_ident", kernel_ident,
                                 SUBSTITUTE("ostype", ostype,                              strlen(kernel_ident));
                                     strlen(ostype));                  } else if (MATCH("domainname")) {
                         } else                          SUBSTITUTE("domainname", domainname,
                                 tmp[newlen++] = '@';                              domainnamelen);
                   } else if (MATCH("ostype")) {
                           SUBSTITUTE("ostype", ostype,
                               strlen(ostype));
                   } else {
                           tmp[newlen++] = '@';
                           if (termchar == VC)
                                   tmp[newlen++] = VO;
                 }                  }
         }          }
   
Line 146  symlink_magic(char *cp, int *len)
Line 170  symlink_magic(char *cp, int *len)
         return (0);          return (0);
 }  }
   
   #undef VNL
   #undef VO
   #undef VC
   #undef MATCH
   #undef SUBSTITUTE
   
 /*  /*
  * Convert a pathname into a pointer to a locked inode.   * Convert a pathname into a pointer to a locked inode.
  *   *
Line 302  namei(struct nameidata *ndp)
Line 332  namei(struct nameidata *ndp)
                  * check length for potential overflow.                   * check length for potential overflow.
                  */                   */
                 if (((ndp->ni_vp->v_mount->mnt_flag & MNT_MAGICLINKS) &&                  if (((ndp->ni_vp->v_mount->mnt_flag & MNT_MAGICLINKS) &&
                      symlink_magic(cp, &linklen)) ||                       symlink_magic(cnp->cn_proc, cp, &linklen)) ||
                     (linklen + ndp->ni_pathlen >= MAXPATHLEN)) {                      (linklen + ndp->ni_pathlen >= MAXPATHLEN)) {
                         error = ENAMETOOLONG;                          error = ENAMETOOLONG;
                         goto badlink;                          goto badlink;

Legend:
Removed from v.1.62  
changed lines
  Added in v.1.63

CVSweb <webmaster@jp.NetBSD.org>