Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 May 2016 21:17:31 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r298901 - head/sbin/restore
Message-ID:  <201605012117.u41LHV7b007197@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Sun May  1 21:17:30 2016
New Revision: 298901
URL: https://svnweb.freebsd.org/changeset/base/298901

Log:
  restore: promote some getfiles() parameters to size_t.
  
  This is based on a change from OpenBSD:
  
  "Fix restore so that it can actually restore files larger than 4GB by
  changing the type of "size" to off_t in getfiles() plus little dependent
  type cleanup, from Daniel Lucq."
  
  It is an important for machines with 32 bit longs.
  While here unsign the flags, also from OpenBSD.
  
  Obtained from:	OpenBSD (through bitrig, I hate CVS)
  MFC after:	2 weeks

Modified:
  head/sbin/restore/dirs.c
  head/sbin/restore/extern.h
  head/sbin/restore/tape.c

Modified: head/sbin/restore/dirs.c
==============================================================================
--- head/sbin/restore/dirs.c	Sun May  1 21:06:59 2016	(r298900)
+++ head/sbin/restore/dirs.c	Sun May  1 21:17:30 2016	(r298901)
@@ -85,7 +85,7 @@ struct modeinfo {
 	mode_t mode;
 	uid_t uid;
 	gid_t gid;
-	int flags;
+	u_int flags;
 	int extsize;
 };
 
@@ -115,8 +115,8 @@ static struct inotab	*allocinotab(struct
 static void		 flushent(void);
 static struct inotab	*inotablookup(ino_t);
 static RST_DIR		*opendirfile(const char *);
-static void		 putdir(char *, long);
-static void		 putdirattrs(char *, long);
+static void		 putdir(char *, size_t);
+static void		 putdirattrs(char *, size_t);
 static void		 putent(struct direct *);
 static void		 rst_seekdir(RST_DIR *, long, long);
 static long		 rst_telldir(RST_DIR *);
@@ -323,10 +323,10 @@ searchdir(ino_t	inum, char *name)
  * Put the directory entries in the directory file
  */
 static void
-putdir(char *buf, long size)
+putdir(char *buf, size_t size)
 {
 	struct direct *dp;
-	long loc, i;
+	size_t loc, i;
 
 	for (loc = 0; loc < size; ) {
 		dp = (struct direct *)(buf + loc);
@@ -356,12 +356,12 @@ putdir(char *buf, long size)
 				   "reclen not multiple of 4 ");
 			if (dp->d_reclen < DIRSIZ(0, dp))
 				vprintf(stdout,
-				   "reclen less than DIRSIZ (%d < %zu) ",
+				   "reclen less than DIRSIZ (%u < %zu) ",
 				   dp->d_reclen, DIRSIZ(0, dp));
 #if NAME_MAX < 255
 			if (dp->d_namlen > NAME_MAX)
 				vprintf(stdout,
-				   "reclen name too big (%d > %d) ",
+				   "reclen name too big (%u > %u) ",
 				   dp->d_namlen, NAME_MAX);
 #endif
 			vprintf(stdout, "\n");
@@ -418,7 +418,7 @@ flushent(void)
  * Save extended attributes for a directory entry to a file.
  */
 static void
-putdirattrs(char *buf, long size)
+putdirattrs(char *buf, size_t size)
 {
 
 	if (mf != NULL && fwrite(buf, size, 1, mf) != 1)

Modified: head/sbin/restore/extern.h
==============================================================================
--- head/sbin/restore/extern.h	Sun May  1 21:06:59 2016	(r298900)
+++ head/sbin/restore/extern.h	Sun May  1 21:17:30 2016	(r298901)
@@ -54,8 +54,8 @@ void		 freeentry(struct entry *);
 void		 freename(char *);
 int	 	 genliteraldir(char *, ino_t);
 char		*gentempname(struct entry *);
-void		 getfile(void (*)(char *, long), void (*)(char *, long),
-			void (*)(char *, long));
+void		 getfile(void (*)(char *, size_t), void (*)(char *, size_t),
+			void (*)(char *, size_t));
 void		 getvol(long);
 void		 initsymtable(char *);
 int	 	 inodetype(ino_t);
@@ -98,7 +98,7 @@ void		 swabst(u_char *, u_char *);
 void	 	 treescan(char *, ino_t, long (*)(char *, ino_t, int));
 ino_t		 upperbnd(ino_t);
 long		 verifyfile(char *, ino_t, int);
-void		 xtrnull(char *, long);
+void		 xtrnull(char *, size_t);
 
 /* From ../dump/dumprmt.c */
 void		rmtclose(void);

Modified: head/sbin/restore/tape.c
==============================================================================
--- head/sbin/restore/tape.c	Sun May  1 21:06:59 2016	(r298900)
+++ head/sbin/restore/tape.c	Sun May  1 21:17:30 2016	(r298901)
@@ -104,10 +104,10 @@ static int	 checksum(int *);
 static void	 findinode(struct s_spcl *);
 static void	 findtapeblksize(void);
 static char	*setupextattr(int);
-static void	 xtrattr(char *, long);
+static void	 xtrattr(char *, size_t);
 static void	 set_extattr_link(char *, void *, int);
 static void	 set_extattr_fd(int, char *, void *, int);
-static void	 skiphole(void (*)(char *, long), long *);
+static void	 skiphole(void (*)(char *, size_t), size_t *);
 static int	 gethead(struct s_spcl *);
 static void	 readtape(char *);
 static void	 setdumpnum(void);
@@ -115,12 +115,12 @@ static u_long	 swabl(u_long);
 static u_char	*swablong(u_char *, int);
 static u_char	*swabshort(u_char *, int);
 static void	 terminateinput(void);
-static void	 xtrfile(char *, long);
-static void	 xtrlnkfile(char *, long);
-static void	 xtrlnkskip(char *, long);
-static void	 xtrmap(char *, long);
-static void	 xtrmapskip(char *, long);
-static void	 xtrskip(char *, long);
+static void	 xtrfile(char *, size_t);
+static void	 xtrlnkfile(char *, size_t);
+static void	 xtrlnkskip(char *, size_t);
+static void	 xtrmap(char *, size_t);
+static void	 xtrmapskip(char *, size_t);
+static void	 xtrskip(char *, size_t);
 
 /*
  * Set up an input source
@@ -566,7 +566,7 @@ printdumpinfo(void)
 int
 extractfile(char *name)
 {
-	int flags;
+	u_int flags;
 	uid_t uid;
 	gid_t gid;
 	mode_t mode;
@@ -932,7 +932,7 @@ skipfile(void)
  * Skip a hole in an output file
  */
 static void
-skiphole(void (*skip)(char *, long), long *seekpos)
+skiphole(void (*skip)(char *, size_t), size_t *seekpos)
 {
 	char buf[MAXBSIZE];
 
@@ -949,14 +949,14 @@ skiphole(void (*skip)(char *, long), lon
  * to the skip function.
  */
 void
-getfile(void (*datafill)(char *, long), void (*attrfill)(char *, long),
-	void (*skip)(char *, long))
+getfile(void (*datafill)(char *, size_t), void (*attrfill)(char *, size_t),
+	void (*skip)(char *, size_t))
 {
 	int i;
-	off_t size;
-	long seekpos;
+	volatile off_t size;
+	size_t seekpos;
 	int curblk, attrsize;
-	void (*fillit)(char *, long);
+	void (*fillit)(char *, size_t);
 	char buf[MAXBSIZE / TP_BSIZE][TP_BSIZE];
 	char junk[TP_BSIZE];
 
@@ -1093,7 +1093,7 @@ setupextattr(int extsize)
  * Extract the next block of extended attributes.
  */
 static void
-xtrattr(char *buf, long size)
+xtrattr(char *buf, size_t size)
 {
 
 	if (extloc + size > extbufsize)
@@ -1106,7 +1106,7 @@ xtrattr(char *buf, long size)
  * Write out the next block of a file.
  */
 static void
-xtrfile(char *buf, long	size)
+xtrfile(char *buf, size_t size)
 {
 
 	if (Nflag)
@@ -1123,7 +1123,7 @@ xtrfile(char *buf, long	size)
  */
 /* ARGSUSED */
 static void
-xtrskip(char *buf, long size)
+xtrskip(char *buf, size_t size)
 {
 
 	if (lseek(ofile, size, SEEK_CUR) == -1) {
@@ -1138,7 +1138,7 @@ xtrskip(char *buf, long size)
  * Collect the next block of a symbolic link.
  */
 static void
-xtrlnkfile(char *buf, long size)
+xtrlnkfile(char *buf, size_t size)
 {
 
 	pathlen += size;
@@ -1155,7 +1155,7 @@ xtrlnkfile(char *buf, long size)
  */
 /* ARGSUSED */
 static void
-xtrlnkskip(char *buf, long size)
+xtrlnkskip(char *buf, size_t size)
 {
 
 	fprintf(stderr, "unallocated block in symbolic link %s\n",
@@ -1167,7 +1167,7 @@ xtrlnkskip(char *buf, long size)
  * Collect the next block of a bit map.
  */
 static void
-xtrmap(char *buf, long size)
+xtrmap(char *buf, size_t size)
 {
 
 	memmove(map, buf, size);
@@ -1179,7 +1179,7 @@ xtrmap(char *buf, long size)
  */
 /* ARGSUSED */
 static void
-xtrmapskip(char *buf, long size)
+xtrmapskip(char *buf, size_t size)
 {
 
 	panic("hole in map\n");
@@ -1191,7 +1191,7 @@ xtrmapskip(char *buf, long size)
  */
 /* ARGSUSED */
 void
-xtrnull(char *buf, long size)
+xtrnull(char *buf, size_t size)
 {
 
 	return;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605012117.u41LHV7b007197>