* Copyright (c) 1989 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)create.c 5.9 (Berkeley) %G%";
int ftsoptions = FTS_PHYSICAL;
register int cnt
, label
, notset
;
char curp
[MAXPATHLEN
], *inotype(), *getlogin(), *rlink();
(void)fprintf(stderr
, "mtree: %s\n", curp
);
(void)printf("#\n#\t fs: %s\n#\t by: %s\n#\tdate: %s#\n",
curp
, getlogin(), ctime(&clock
));
if (!(t
= ftsopen(".", ftsoptions
, dsort
))) {
"mtree: ftsopen: %s.\n", strerror(errno
));
statdir(t
, p
, &uid
, &gid
, &mode
, &tabs
);
if (!strcmp(p
->fts_name
, "."))
"mtree: directory cycle: %s.\n", p
->fts_path
);
"mtree: %s: unable to read.\n", p
->fts_path
);
"mtree: %s: unable to search.\n", p
->fts_path
);
for (cnt
= p
->fts_level
- 1; cnt
-- > 0; )
(void)fprintf(stderr
, "mtree: %s: %s.\n",
p
->fts_path
, strerror(errno
));
"mtree: can't stat: %s.\n", p
->fts_path
);
for (cnt
= p
->fts_level
- 1; cnt
-- > 0; )
(void)printf("%s", p
->fts_name
);
if (p
->fts_info
== FTS_D
)
if (tabs
> 1 && p
->fts_namelen
< 8)
if (!S_ISREG(p
->fts_statb
.st_mode
) || notset
) {
(void)printf("type=%s", inotype(p
->fts_statb
.st_mode
));
if (p
->fts_statb
.st_uid
!= uid
|| notset
) {
(void)printf("owner=%u", p
->fts_statb
.st_uid
);
if (p
->fts_statb
.st_gid
!= gid
|| notset
) {
(void)printf("group=%u", p
->fts_statb
.st_gid
);
if ((p
->fts_statb
.st_mode
& MBITS
) != mode
|| notset
) {
(void)printf("mode=%#o", p
->fts_statb
.st_mode
& MBITS
);
if (p
->fts_statb
.st_nlink
!= 1 || notset
) {
(void)printf("nlink=%u", p
->fts_statb
.st_nlink
);
(void)printf("size=%ld", p
->fts_statb
.st_size
);
if (p
->fts_info
== FTS_SL
|| p
->fts_info
== FTS_SLNONE
) {
(void)printf("link=%s", rlink(p
->fts_accpath
));
#define MAXMODE MBITS + 1
statdir(t
, parent
, puid
, pgid
, pmode
, tabs
)
u_short maxgid
, maxuid
, maxmode
, g
[MAXGID
], u
[MAXUID
], m
[MAXMODE
];
if (!(p
= ftschildren(t
))) {
(void)fprintf(stderr
, "mtree: %s: %s.\n",
RP(parent
), strerror(errno
));
maxuid
= maxgid
= maxmode
= 0;
for (; p
; p
= p
->fts_link
) {
mode
= p
->fts_statb
.st_mode
& MBITS
;
if (mode
< MAXMODE
&& ++m
[mode
] > maxmode
) {
gid
= p
->fts_statb
.st_gid
;
if (gid
< MAXGID
&& ++g
[gid
] > maxgid
) {
uid
= p
->fts_statb
.st_uid
;
if (uid
< MAXUID
&& ++u
[uid
] > maxuid
) {
(void)printf("\n/set group=%u mode=%#o nlink=1 owner=%u type=file\n",
savegid
, savemode
, saveuid
);
if (S_ISDIR(a
->fts_statb
.st_mode
)) {
if (!S_ISDIR(b
->fts_statb
.st_mode
))
} else if (S_ISDIR(b
->fts_statb
.st_mode
))
return(strcmp(a
->fts_name
, b
->fts_name
));