8 /* Return matching pathname prefix length, or zero if not matching */
9 static inline int match_pathname(int len
, const char *name
, struct pathname
*match
)
11 int match_len
= match
->len
;
12 return (len
> match_len
&&
13 name
[match_len
] == '/' &&
14 !memcmp(name
, match
->path
, match_len
)) ? match_len
: 0;
17 static inline void set_pathname(int len
, const char *name
, struct pathname
*match
)
21 memcpy(match
->path
, name
, len
);
26 int has_symlink_leading_path(int len
, const char *name
)
28 static struct pathname link
, nonlink
;
35 * See if the last known symlink cache matches.
37 if (match_pathname(len
, name
, &link
))
41 * Get rid of the last known directory part
43 known_dir
= match_pathname(len
, name
, &nonlink
);
45 while ((sp
= strchr(name
+ known_dir
+ 1, '/')) != NULL
) {
46 int thislen
= sp
- name
;
47 memcpy(path
, name
, thislen
);
52 if (S_ISDIR(st
.st_mode
)) {
53 set_pathname(thislen
, path
, &nonlink
);
57 if (S_ISLNK(st
.st_mode
)) {
58 set_pathname(thislen
, path
, &link
);