SCCS-vsn: usr.sbin/mtree/mtree.h 5.4
SCCS-vsn: usr.sbin/mtree/spec.c 5.6
SCCS-vsn: usr.sbin/mtree/verify.c 5.3
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)mtree.h 5.3 (Berkeley) %G%
+ * @(#)mtree.h 5.4 (Berkeley) %G%
#define F_TYPE 0x100 /* file type */
u_short flags; /* items set */
#define F_TYPE 0x100 /* file type */
u_short flags; /* items set */
+ off_t st_size; /* size */
u_long cksum; /* check sum */
u_long cksum; /* check sum */
- uid_t st_uid;
- gid_t st_gid;
+ uid_t st_uid; /* owner */
+ gid_t st_gid; /* group */
#define MBITS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
#define MBITS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
- mode_t st_mode;
- nlink_t st_nlink;
+ mode_t st_mode; /* mode */
+ nlink_t st_nlink; /* link count */
char *slink; /* symbolic link reference */
} INFO;
char *slink; /* symbolic link reference */
} INFO;
struct _entry *next, *prev; /* left, right */
INFO info; /* node info structure */
#define F_DONE 0x01 /* directory done */
struct _entry *next, *prev; /* left, right */
INFO info; /* node info structure */
#define F_DONE 0x01 /* directory done */
-#define F_VISIT 0x02 /* visited this node */
+#define F_MAGIC 0x02 /* name has magic chars */
+#define F_VISIT 0x04 /* visited this node */
u_char flags; /* flags */
u_char flags; /* flags */
- char *name; /* node name */
+ char name[1]; /* file name (must be last) */
} ENTRY;
#define RP(p) (p->fts_path + 2)
} ENTRY;
#define RP(p) (p->fts_path + 2)
-static char sccsid[] = "@(#)spec.c 5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)spec.c 5.6 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
ENTRY *centry, *last;
INFO info, ginfo;
char buf[2048];
ENTRY *centry, *last;
INFO info, ginfo;
char buf[2048];
ginfo.flags = info.flags = 0;
ginfo.type = info.type = F_NONE;
ginfo.flags = info.flags = 0;
ginfo.type = info.type = F_NONE;
- centry = (ENTRY *)emalloc(sizeof(ENTRY));
- if (!(centry->name = strdup(p)))
- nomem();
+ centry = emalloc(sizeof(ENTRY) + strlen(p));
+ (void)strcpy(centry->name, p);
+#define MAGIC "?*["
+ if (strpbrk(p, MAGIC))
+ centry->flags |= F_MAGIC;
centry->info = ginfo;
set(¢ry->info);
centry->info = ginfo;
set(¢ry->info);
emalloc(size)
int size;
{
emalloc(size)
int size;
{
if (!(p = malloc((u_int)size)))
nomem();
bzero(p, size);
if (!(p = malloc((u_int)size)))
nomem();
bzero(p, size);
-static char sccsid[] = "@(#)verify.c 5.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)verify.c 5.3 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fts.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <dirent.h>
#include <fts.h>
#include <errno.h>
#include <stdio.h>
#include "mtree.h"
#include <errno.h>
#include <stdio.h>
#include "mtree.h"
}
for (ep = level; ep; ep = ep->next)
}
for (ep = level; ep; ep = ep->next)
- if (!strcmp(ep->name, p->fts_name)) {
+ if (ep->flags & F_MAGIC && fnmatch(ep->name,
+ p->fts_name, FNM_PATHNAME|FNM_QUOTE) ||
+ !strcmp(ep->name, p->fts_name)) {
ep->flags |= F_VISIT;
if (ep->info.flags&F_IGN) {
(void)ftsset(t, p, FTS_SKIP);
ep->flags |= F_VISIT;
if (ep->info.flags&F_IGN) {
(void)ftsset(t, p, FTS_SKIP);