[BACK]Return to xinstall.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / xinstall

Diff for /src/usr.bin/xinstall/xinstall.c between version 1.57 and 1.58

version 1.57, 2014/05/20 01:25:23 version 1.58, 2015/01/16 06:40:15
Line 30 
Line 30 
  * SUCH DAMAGE.   * SUCH DAMAGE.
  */   */
   
 #include <sys/param.h>  #include <sys/param.h>  /* MAXBSIZE */
 #include <sys/wait.h>  #include <sys/wait.h>
 #include <sys/mman.h>  #include <sys/mman.h>
 #include <sys/stat.h>  #include <sys/stat.h>
Line 46 
Line 46 
 #include <stdlib.h>  #include <stdlib.h>
 #include <string.h>  #include <string.h>
 #include <unistd.h>  #include <unistd.h>
   #include <limits.h>
 #include <sysexits.h>  #include <sysexits.h>
 #include <utime.h>  #include <utime.h>
   
 #include "pathnames.h"  #include "pathnames.h"
   
   #define MINIMUM(a, b)   (((a) < (b)) ? (a) : (b))
   
 #define DIRECTORY       0x01            /* Tell install it's a directory. */  #define DIRECTORY       0x01            /* Tell install it's a directory. */
 #define SETFLAGS        0x02            /* Tell install to set flags. */  #define SETFLAGS        0x02            /* Tell install to set flags. */
 #define NOCHANGEBITS    (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND)  #define NOCHANGEBITS    (UF_IMMUTABLE | UF_APPEND | SF_IMMUTABLE | SF_APPEND)
Line 60 
Line 63 
 struct group *gp;  struct group *gp;
 int dobackup, docompare, dodir, dopreserve, dostrip, safecopy;  int dobackup, docompare, dodir, dopreserve, dostrip, safecopy;
 int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;  int mode = S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
 char pathbuf[MAXPATHLEN], tempfile[MAXPATHLEN];  char pathbuf[PATH_MAX], tempfile[PATH_MAX];
 char *suffix = BACKUP_SUFFIX;  char *suffix = BACKUP_SUFFIX;
 uid_t uid;  uid_t uid;
 gid_t gid;  gid_t gid;
Line 372 
Line 375 
                 if (to_sb.st_flags & (NOCHANGEBITS))                  if (to_sb.st_flags & (NOCHANGEBITS))
                         (void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS));                          (void)chflags(to_name, to_sb.st_flags & ~(NOCHANGEBITS));
                 if (dobackup) {                  if (dobackup) {
                         char backup[MAXPATHLEN];                          char backup[PATH_MAX];
                         (void)snprintf(backup, MAXPATHLEN, "%s%s", to_name,                          (void)snprintf(backup, PATH_MAX, "%s%s", to_name,
                             suffix);                              suffix);
                         /* It is ok for the target file not to exist. */                          /* It is ok for the target file not to exist. */
                         if (rename(to_name, backup) < 0 && errno != ENOENT) {                          if (rename(to_name, backup) < 0 && errno != ENOENT) {
Line 498 
Line 501 
         from_off = to_off = (off_t)0;          from_off = to_off = (off_t)0;
         remainder = from_len;          remainder = from_len;
         do {          do {
                 length = MIN(remainder, 8 * 1048576);                  length = MINIMUM(remainder, 8 * 1048576);
                 remainder -= length;                  remainder -= length;
   
                 if ((p1 = mmap(NULL, length, PROT_READ, MAP_PRIVATE,                  if ((p1 = mmap(NULL, length, PROT_READ, MAP_PRIVATE,
Line 632 
Line 635 
 int  int
 create_newfile(char *path, struct stat *sbp)  create_newfile(char *path, struct stat *sbp)
 {  {
         char backup[MAXPATHLEN];          char backup[PATH_MAX];
   
         /*          /*
          * Unlink now... avoid ETXTBSY errors later.  Try and turn           * Unlink now... avoid ETXTBSY errors later.  Try and turn
Line 643 
Line 646 
                 (void)chflags(path, sbp->st_flags & ~(NOCHANGEBITS));                  (void)chflags(path, sbp->st_flags & ~(NOCHANGEBITS));
   
         if (dobackup) {          if (dobackup) {
                 (void)snprintf(backup, MAXPATHLEN, "%s%s", path, suffix);                  (void)snprintf(backup, PATH_MAX, "%s%s", path, suffix);
                 /* It is ok for the target file not to exist. */                  /* It is ok for the target file not to exist. */
                 if (rename(path, backup) < 0 && errno != ENOENT)                  if (rename(path, backup) < 0 && errno != ENOENT)
                         err(EX_OSERR, "rename: %s to %s (errno %d)", path, backup, errno);                          err(EX_OSERR, "rename: %s to %s (errno %d)", path, backup, errno);
Line 729 
Line 732 
                  * only examine up to the end of the current file block or                   * only examine up to the end of the current file block or
                  * remaining characters to write, whatever is smaller                   * remaining characters to write, whatever is smaller
                  */                   */
                 wcnt = MIN(cnt, *rem);                  wcnt = MINIMUM(cnt, *rem);
                 cnt -= wcnt;                  cnt -= wcnt;
                 *rem -= wcnt;                  *rem -= wcnt;
                 if (*isempt) {                  if (*isempt) {

Legend:
Removed from v.1.57  
changed lines
  Added in v.1.58