]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
remove unused lxc_copy_file
authorDwight Engen <dwight.engen@oracle.com>
Wed, 10 Apr 2013 14:49:51 +0000 (10:49 -0400)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Wed, 10 Apr 2013 20:24:29 +0000 (15:24 -0500)
Commit e3642c43 added lxc_copy_file for use in 64e1ae63. The use of it
was removed in commit 1bc60a65. Removing it reduces dead code and the
footprint of liblxc.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/utils.c
src/lxc/utils.h

index f4ba905208ba9469309bd256952c88c546189581..ecf9d2c77c9a22b67233d186ad8543896f01bcd5 100644 (file)
 
 lxc_log_define(lxc_utils, lxc);
 
-int lxc_copy_file(const char *srcfile, const char *dstfile)
-{
-       void *srcaddr = NULL, *dstaddr;
-       struct stat stat;
-       int srcfd, dstfd, ret = -1;
-       char c = '\0';
-
-       dstfd = open(dstfile, O_CREAT | O_EXCL | O_RDWR, 0600);
-       if (dstfd < 0) {
-               SYSERROR("failed to creat '%s'", dstfile);
-               goto out;
-       }
-
-       srcfd = open(srcfile, O_RDONLY);
-       if (srcfd < 0) {
-               SYSERROR("failed to open '%s'", srcfile);
-               goto err;
-       }
-
-       if (fstat(srcfd, &stat)) {
-               SYSERROR("failed to stat '%s'", srcfile);
-               goto err;
-       }
-
-       if (!stat.st_size) {
-               INFO("copy '%s' which is an empty file", srcfile);
-               ret = 0;
-               goto out_close;
-       }
-
-       if (lseek(dstfd, stat.st_size - 1, SEEK_SET) < 0) {
-               SYSERROR("failed to seek dest file '%s'", dstfile);
-               goto err;
-       }
-
-       /* fixup length */
-       if (write(dstfd, &c, 1) < 0) {
-               SYSERROR("failed to write to '%s'", dstfile);
-               goto err;
-       }
-
-       srcaddr = mmap(NULL, stat.st_size, PROT_READ, MAP_SHARED, srcfd, 0L);
-       if (srcaddr == MAP_FAILED) {
-               SYSERROR("failed to mmap '%s'", srcfile);
-               goto err;
-       }
-
-       dstaddr = mmap(NULL, stat.st_size, PROT_WRITE, MAP_SHARED, dstfd, 0L);
-       if (dstaddr == MAP_FAILED) {
-               SYSERROR("failed to mmap '%s'", dstfile);
-               goto err;
-       }
-
-       ret = 0;
-
-       memcpy(dstaddr, srcaddr, stat.st_size);
-
-       munmap(dstaddr, stat.st_size);
-out_mmap:
-       if (srcaddr)
-               munmap(srcaddr, stat.st_size);
-out_close:
-       close(dstfd);
-       close(srcfd);
-out:
-       return ret;
-err:
-       unlink(dstfile);
-       goto out_mmap;
-}
-
 static int mount_fs(const char *source, const char *target, const char *type)
 {
        /* the umount may fail */
index bf5b6cdc66197c19c083c381bab9512521ce8e8c..8954503a3d1ba5acb1c87a8c2a012b825e0c361b 100644 (file)
@@ -23,7 +23,6 @@
 #ifndef _utils_h
 #define _utils_h
 
-extern int lxc_copy_file(const char *src, const char *dst);
 extern int lxc_setup_fs(void);
 extern int get_u16(unsigned short *val, const char *arg, int base);
 extern int mkdir_p(const char *dir, mode_t mode);