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]
24 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 /* All Rights Reserved */
32 #include <sys/types.h>
42 extern int access(), rm_files();
44 static char cmdbuf
[SBUFSZ
]; /* buffer for system call */
47 * Move directory contents from one place to another
50 move_dir(char *from
, char *to
, char *login
, int flags
)
51 /* directory to move files from */
52 /* dirctory to move files to */
53 /* login id of owner */
54 /* miscellaneous flags */
61 * ***** THIS IS WHERE SUFFICIENT SPACE CHECK GOES
64 if (access(from
, F_OK
) == 0) { /* home dir exists */
66 (void) sprintf(cmdbuf
,
67 "cd %s && find . -print | cpio -m -pd %s",
70 if (system(cmdbuf
) != 0) {
71 errmsg(M_NOSPACE
, from
, to
);
76 * Check that to dir is not a subdirectory of from
79 if (strncmp(from
, to
, len
) == 0 &&
80 strncmp(to
+len
, "/", 1) == 0) {
84 /* Retain the original permission and modification time */
85 if (stat(from
, &statbuf
) == 0) {
86 chmod(to
, statbuf
.st_mode
);
87 times
.actime
= statbuf
.st_atime
;
88 times
.modtime
= statbuf
.st_mtime
;
89 (void) utime(to
, ×
);
93 /* Remove the files in the old place */
94 rc
= rm_files(from
, login
, flags
);