am 82a2687a: Merge "Fix cp(1) for files in /proc."

* commit '82a2687a3c7eb39549b07153cf6a87ce5f3b507f':
  Fix cp(1) for files in /proc.
This commit is contained in:
Elliott Hughes 2014-07-22 20:32:13 +00:00 committed by Android Git Automerger
commit 1ff2df3f64
2 changed files with 12 additions and 12 deletions

View file

@ -95,7 +95,7 @@ enum op { FILE_TO_FILE, FILE_TO_DIR, DIR_TO_DNE };
static int copy(char *[], enum op, int); static int copy(char *[], enum op, int);
#ifndef ANDROID #ifndef __ANDROID__
static void static void
progress(int sig __unused) progress(int sig __unused)
{ {
@ -112,9 +112,7 @@ cp_main(int argc, char *argv[])
int ch, fts_options, r, have_trailing_slash; int ch, fts_options, r, have_trailing_slash;
char *target, **src; char *target, **src;
#ifndef ANDROID
setprogname(argv[0]); setprogname(argv[0]);
#endif
(void)setlocale(LC_ALL, ""); (void)setlocale(LC_ALL, "");
Hflag = Lflag = Pflag = Rflag = 0; Hflag = Lflag = Pflag = Rflag = 0;
@ -222,7 +220,7 @@ cp_main(int argc, char *argv[])
/* Set end of argument list for fts(3). */ /* Set end of argument list for fts(3). */
argv[argc] = NULL; argv[argc] = NULL;
#ifndef ANDROID #ifndef __ANDROID__
(void)signal(SIGINFO, progress); (void)signal(SIGINFO, progress);
#endif #endif

View file

@ -42,7 +42,7 @@ __RCSID("$NetBSD: utils.c,v 1.41 2012/01/04 15:58:37 christos Exp $");
#include <sys/param.h> #include <sys/param.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h> #include <sys/time.h>
#ifndef ANDROID #ifndef __ANDROID__
#include <sys/extattr.h> #include <sys/extattr.h>
#endif #endif
@ -58,7 +58,7 @@ __RCSID("$NetBSD: utils.c,v 1.41 2012/01/04 15:58:37 christos Exp $");
#include "extern.h" #include "extern.h"
#ifdef ANDROID #ifdef __ANDROID__
#define MAXBSIZE 65536 #define MAXBSIZE 65536
#endif #endif
@ -70,7 +70,7 @@ set_utimes(const char *file, struct stat *fs)
{ {
static struct timeval tv[2]; static struct timeval tv[2];
#ifdef ANDROID #ifdef __ANDROID__
tv[0].tv_sec = fs->st_atime; tv[0].tv_sec = fs->st_atime;
tv[0].tv_usec = 0; tv[0].tv_usec = 0;
tv[1].tv_sec = fs->st_mtime; tv[1].tv_sec = fs->st_mtime;
@ -198,7 +198,9 @@ copy_file(FTSENT *entp, int dne)
* There's no reason to do anything other than close the file * There's no reason to do anything other than close the file
* now if it's empty, so let's not bother. * now if it's empty, so let's not bother.
*/ */
#ifndef __ANDROID__ // Files in /proc report length 0. mmap will fail but we'll fall back to read.
if (fs->st_size > 0) { if (fs->st_size > 0) {
#endif
struct finfo fi; struct finfo fi;
fi.from = entp->fts_path; fi.from = entp->fts_path;
@ -273,9 +275,11 @@ copy_file(FTSENT *entp, int dne)
rval = 1; rval = 1;
} }
} }
#ifndef __ANDROID__
} }
#endif
#ifndef ANDROID #ifndef __ANDROID__
if (pflag && (fcpxattr(from_fd, to_fd) != 0)) if (pflag && (fcpxattr(from_fd, to_fd) != 0))
warn("%s: error copying extended attributes", to.p_path); warn("%s: error copying extended attributes", to.p_path);
#endif #endif
@ -381,9 +385,7 @@ int
setfile(struct stat *fs, int fd) setfile(struct stat *fs, int fd)
{ {
int rval = 0; int rval = 0;
#ifndef ANDROID
int islink = S_ISLNK(fs->st_mode); int islink = S_ISLNK(fs->st_mode);
#endif
fs->st_mode &= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO; fs->st_mode &= S_ISUID | S_ISGID | S_IRWXU | S_IRWXG | S_IRWXO;
@ -401,7 +403,7 @@ setfile(struct stat *fs, int fd)
} }
fs->st_mode &= ~(S_ISUID | S_ISGID); fs->st_mode &= ~(S_ISUID | S_ISGID);
} }
#ifdef ANDROID #ifdef __ANDROID__
if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) { if (fd ? fchmod(fd, fs->st_mode) : chmod(to.p_path, fs->st_mode)) {
#else #else
if (fd ? fchmod(fd, fs->st_mode) : lchmod(to.p_path, fs->st_mode)) { if (fd ? fchmod(fd, fs->st_mode) : lchmod(to.p_path, fs->st_mode)) {
@ -410,7 +412,7 @@ setfile(struct stat *fs, int fd)
rval = 1; rval = 1;
} }
#ifndef ANDROID #ifndef __ANDROID__
if (!islink && !Nflag) { if (!islink && !Nflag) {
unsigned long fflags = fs->st_flags; unsigned long fflags = fs->st_flags;
/* /*