cpdir.c (476602a9d0b9041b42a108349dc58a4ca6bf4223) cpdir.c (1dcc6ec750ce84c42fee6fb29a88c20b3b91f4ed)
1/*-
2 * Copyright (C) 1996
3 * David L. Nugent. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * ARE DISCLAIMED. IN NO EVENT SHALL DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
1/*-
2 * Copyright (C) 1996
3 * David L. Nugent. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 8 unchanged lines hidden (view full) ---

17 * ARE DISCLAIMED. IN NO EVENT SHALL DAVID L. NUGENT OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $Id$
27 */
28
25 */
26
27#ifndef lint
28static const char rcsid[] =
29 "$Id$";
30#endif /* not lint */
31
32#include <err.h>
33#include <errno.h>
34#include <fcntl.h>
29#include <stdio.h>
30#include <string.h>
31#include <stdlib.h>
35#include <stdio.h>
36#include <string.h>
37#include <stdlib.h>
32#include <fcntl.h>
38#include <unistd.h>
33#include <sys/types.h>
34#include <sys/stat.h>
39#include <sys/types.h>
40#include <sys/stat.h>
35#include <dirent.h>
36#include <unistd.h>
37#include <sys/param.h>
41#include <sys/param.h>
38#include <errno.h>
42#include <dirent.h>
39
40#include "pwupd.h"
41
42void
43copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid)
44{
45 int rc = 0;
46 char src[MAXPATHLEN];
47 char dst[MAXPATHLEN];
48
49 if (mkdir(dir, mode) != 0 && errno != EEXIST) {
43
44#include "pwupd.h"
45
46void
47copymkdir(char const * dir, char const * skel, mode_t mode, uid_t uid, gid_t gid)
48{
49 int rc = 0;
50 char src[MAXPATHLEN];
51 char dst[MAXPATHLEN];
52
53 if (mkdir(dir, mode) != 0 && errno != EEXIST) {
50 sprintf(src, "mkdir(%s)", dir);
51 perror(src);
54 warn("mkdir(%s)", dir);
52 } else {
53 int infd, outfd;
54 struct stat st;
55
56 static char counter = 0;
57 static char *copybuf = NULL;
58
59 ++counter;

--- 54 unchanged lines hidden ---
55 } else {
56 int infd, outfd;
57 struct stat st;
58
59 static char counter = 0;
60 static char *copybuf = NULL;
61
62 ++counter;

--- 54 unchanged lines hidden ---