The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/tests/zfs-tests/cmd/cp_files.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <unistd.h>
    4 #include <sys/types.h>
    5 #include <sys/stat.h>
    6 #include <fcntl.h>
    7 #include <dirent.h>
    8 #include <errno.h>
    9 #include <string.h>
   10 
   11 int
   12 main(int argc, char *argv[])
   13 {
   14         int tfd;
   15         DIR *sdir;
   16         struct dirent *dirent;
   17 
   18         if (argc != 3) {
   19                 fprintf(stderr, "Usage: %s SRC DST\n", argv[0]);
   20                 exit(1);
   21         }
   22 
   23         sdir = opendir(argv[1]);
   24         if (sdir == NULL) {
   25                 fprintf(stderr, "Failed to open %s: %s\n",
   26                     argv[1], strerror(errno));
   27                 exit(2);
   28         }
   29 
   30         tfd = open(argv[2], O_DIRECTORY);
   31         if (tfd < 0) {
   32                 fprintf(stderr, "Failed to open %s: %s\n",
   33                     argv[2], strerror(errno));
   34                 closedir(sdir);
   35                 exit(3);
   36         }
   37 
   38         while ((dirent = readdir(sdir)) != NULL) {
   39                 if (dirent->d_name[0] == '.' &&
   40                     (dirent->d_name[1] == '.' || dirent->d_name[1] == '\0'))
   41                         continue;
   42 
   43                 int fd = openat(tfd, dirent->d_name, O_CREAT|O_WRONLY, 0666);
   44                 if (fd < 0) {
   45                         fprintf(stderr, "Failed to create %s/%s: %s\n",
   46                             argv[2], dirent->d_name, strerror(errno));
   47                         closedir(sdir);
   48                         close(tfd);
   49                         exit(4);
   50                 }
   51                 close(fd);
   52         }
   53 
   54         closedir(sdir);
   55         close(tfd);
   56 
   57         return (0);
   58 }

Cache object: d139c24f8be57fb77dac4a2c6e23bfaf


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.