strsvis(3) encode & decode the "link=" value (symlink target).

This commit is contained in:
lukem 2004-12-01 10:07:56 +00:00
parent 416a47df13
commit 507e9f7256
2 changed files with 12 additions and 9 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: create.c,v 1.45 2004/06/20 22:20:18 jmc Exp $ */
/* $NetBSD: create.c,v 1.46 2004/12/01 10:07:56 lukem Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: create.c,v 1.45 2004/06/20 22:20:18 jmc Exp $");
__RCSID("$NetBSD: create.c,v 1.46 2004/12/01 10:07:56 lukem Exp $");
#endif
#endif /* not lint */
@ -145,14 +145,13 @@ statf(FTSENT *p)
{
u_int32_t len, val;
int fd, indent;
const char *name, *path;
const char *name;
#if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1)
char digestbuf[41]; /* large enough for {MD5,RMD160,SHA1}File() */
#endif
path = vispath(p->fts_name);
indent = printf("%s%s",
S_ISDIR(p->fts_statp->st_mode) ? "" : " ", path);
S_ISDIR(p->fts_statp->st_mode) ? "" : " ", vispath(p->fts_name));
if (indent > INDENTNAMELEN)
indent = MAXLINELEN;
@ -223,7 +222,7 @@ statf(FTSENT *p)
#endif /* ! NO_SHA1 */
if (keys & F_SLINK &&
(p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE))
output(&indent, "link=%s", rlink(p->fts_accpath));
output(&indent, "link=%s", vispath(rlink(p->fts_accpath)));
#if HAVE_STRUCT_STAT_ST_FLAGS
if (keys & F_FLAGS && p->fts_statp->st_flags != flags)
output(&indent, "flags=%s",

View File

@ -1,4 +1,4 @@
/* $NetBSD: spec.c,v 1.57 2004/07/22 16:51:45 lukem Exp $ */
/* $NetBSD: spec.c,v 1.58 2004/12/01 10:07:56 lukem Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -74,7 +74,7 @@
#if 0
static char sccsid[] = "@(#)spec.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: spec.c,v 1.57 2004/07/22 16:51:45 lukem Exp $");
__RCSID("$NetBSD: spec.c,v 1.58 2004/12/01 10:07:56 lukem Exp $");
#endif
#endif /* not lint */
@ -348,7 +348,7 @@ dump_nodes(const char *dir, NODE *root, int pathlast)
if (MATCHFLAG(F_NLINK))
printf("nlink=%d ", cur->st_nlink);
if (MATCHFLAG(F_SLINK))
printf("link=%s ", cur->slink);
printf("link=%s ", vispath(cur->slink));
if (MATCHFLAG(F_SIZE))
printf("size=%lld ", (long long)cur->st_size);
if (MATCHFLAG(F_TIME))
@ -462,6 +462,8 @@ replacenode(NODE *cur, NODE *new)
REPLACE(st_size);
REPLACE(st_mtimespec);
REPLACESTR(slink);
if (strunvis(cur->slink, new->slink) == -1)
mtree_err("strunvis failed on `%s'", new->slink);
REPLACE(st_uid);
REPLACE(st_gid);
REPLACE(st_mode);
@ -578,6 +580,8 @@ set(char *t, NODE *ip)
case F_SLINK:
if ((ip->slink = strdup(val)) == NULL)
mtree_err("memory allocation error");
if (strunvis(ip->slink, val) == -1)
mtree_err("strunvis failed on `%s'", val);
break;
case F_TAGS:
len = strlen(val) + 3; /* "," + str + ",\0" */