4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1998,2001 by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
36 static dev_t
devfromopts(struct mntent
*);
37 static int lf_mark_root(dev_t
, char *);
38 static int lf_ftw_mark(const char *, const struct stat64
*, int);
39 static void markino(ino_t
);
41 static dev_t
devfromopts();
42 static int lf_mark_root();
43 static int lf_ftw_mark();
44 static void markino();
57 if (stat64(disk
, &st
) < 0 ||
58 (st
.st_mode
& S_IFMT
) == S_IFCHR
||
59 (st
.st_mode
& S_IFMT
) == S_IFBLK
)
62 partial_dev
= st
.st_dev
;
65 while (mnt
= getmnttab()) {
66 st
.st_dev
= devfromopts(mnt
);
67 if (st
.st_dev
== NODEV
&&
68 stat64(mnt
->mnt_dir
, &st
) < 0)
70 if (partial_dev
== st
.st_dev
) {
72 /* LINTED: disk is not NULL */
75 disk
= rawname(mnt
->mnt_fsname
);
76 disk_dynamic
= (disk
!= mnt
->mnt_fsname
);
84 msg(gettext("`%s' is not on a locally mounted filesystem\n"), disk
);
90 * The device id for the mount should be available in
91 * the mount option string as "dev=%04x". If it's there
92 * extract the device id and avoid having to stat.
100 str
= hasmntopt(mnt
, MNTINFO_DEV
);
101 if (str
!= NULL
&& (str
= strchr(str
, '=')))
102 return ((dev_t
)strtol(str
+ 1, (char **)NULL
, 16));
108 partial_mark(argc
, argv
)
118 while (--argc
>= 0) {
121 if (stat64(path
, &st
) < 0 ||
122 st
.st_dev
!= partial_dev
) {
123 msg(gettext("`%s' is not on dump device `%s'\n"),
129 if (lf_mark_root(partial_dev
, path
)) {
131 "Cannot find filesystem mount point for `%s'\n"),
137 /* LINTED this ulimit will always be < INT_MAX */
138 if (lf_lftw(path
, lf_ftw_mark
, (int)ulimit(UL_GDESLIM
, 0) / 2)
141 msg(gettext("Error in %s (%s)\n"),
142 "ftw", strerror(saverr
));
151 /* mark directories between target and root */
153 lf_mark_root(dev
, path
)
158 char dotdot
[MAXPATHLEN
+ 16];
161 if (strlen(path
) > sizeof (dotdot
))
164 (void) strcpy(dotdot
, path
);
166 if (stat64(dotdot
, &st
) < 0)
169 /* if target is a regular file, find directory */
170 if ((st
.st_mode
& S_IFMT
) != S_IFDIR
)
171 if (slash
= strrchr(dotdot
, '/'))
175 /* "dir/file" -> "dir" */
180 (void) strcpy(dotdot
, ".");
182 /* keep marking parent until we hit mount point */
184 if (stat64(dotdot
, &st
) < 0 ||
185 (st
.st_mode
& S_IFMT
) != S_IFDIR
||
189 if (strlen(dotdot
) > (sizeof (dotdot
) - 4))
191 (void) strcat(dotdot
, "/..");
192 } while (st
.st_ino
!= 2);
199 lf_ftw_mark(name
, st
, flag
)
202 const struct stat64
*st
;
209 if (flag
!= FTW_NS
) {
210 /* LINTED ufs only uses the lower 32 bits */
211 markino((ino_t
)st
->st_ino
);
222 dp
= getino(ino
= i
);