Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 9 Mar 2010 10:31:03 +0000 (UTC)
From:      Maxim Sobolev <sobomax@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r204909 - head/sbin/newfs
Message-ID:  <201003091031.o29AV3JO088200@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: sobomax
Date: Tue Mar  9 10:31:03 2010
New Revision: 204909
URL: http://svn.freebsd.org/changeset/base/204909

Log:
  Change secrorsize back to int, since that's the data type expected by the
  ioctl(DIOCGSECTORSIZE). It creates issues on some architectures.
  
  MFC after:	1 week
  Reported by:	Jayachandran C.

Modified:
  head/sbin/newfs/newfs.c
  head/sbin/newfs/newfs.h

Modified: head/sbin/newfs/newfs.c
==============================================================================
--- head/sbin/newfs/newfs.c	Tue Mar  9 06:43:35 2010	(r204908)
+++ head/sbin/newfs/newfs.c	Tue Mar  9 10:31:03 2010	(r204909)
@@ -92,7 +92,7 @@ int	Jflag;			/* enable gjournal for file
 int	lflag;			/* enable multilabel for file system */
 int	nflag;			/* do not create .snap directory */
 intmax_t fssize;		/* file system size */
-int64_t	sectorsize;		/* bytes/sector */
+int	sectorsize;		/* bytes/sector */
 int	realsectorsize;		/* bytes/sector in hardware */
 int64_t	fsize = 0;		/* fragment size */
 int64_t	bsize = 0;		/* block size */
@@ -119,6 +119,7 @@ static void getfssize(intmax_t *, const 
 static struct disklabel *getdisklabel(char *s);
 static void rewritelabel(char *s, struct disklabel *lp);
 static void usage(void);
+static int expand_number_int(const char *buf, int *num);
 
 ufs2_daddr_t part_ofs; /* partition offset in blocks, used with files */
 
@@ -171,7 +172,7 @@ main(int argc, char *argv[])
 			Rflag = 1;
 			break;
 		case 'S':
-			rval = expand_number(optarg, &sectorsize);
+			rval = expand_number_int(optarg, &sectorsize);
 			if (rval < 0 || sectorsize <= 0)
 				errx(1, "%s: bad sector size", optarg);
 			break;
@@ -496,3 +497,20 @@ usage()
 	fprintf(stderr, "\t-s file system size (sectors)\n");
 	exit(1);
 }
+
+static int
+expand_number_int(const char *buf, int *num)
+{
+	int64_t num64;
+	int rval;
+
+	rval = expand_number(buf, &num64);
+	if (rval != 0)
+		return (rval);
+	if (num64 > INT_MAX) {
+		errno = ERANGE;
+		return (-1);
+	}
+	*num = (int)num64;
+	return (0);
+}

Modified: head/sbin/newfs/newfs.h
==============================================================================
--- head/sbin/newfs/newfs.h	Tue Mar  9 06:43:35 2010	(r204908)
+++ head/sbin/newfs/newfs.h	Tue Mar  9 10:31:03 2010	(r204909)
@@ -86,7 +86,7 @@ extern int	Jflag;		/* enable gjournal fo
 extern int	lflag;		/* enable multilabel MAC for file system */
 extern int	nflag;		/* do not create .snap directory */
 extern intmax_t	fssize;		/* file system size */
-extern int64_t	sectorsize;	/* bytes/sector */
+extern int	sectorsize;	/* bytes/sector */
 extern int	realsectorsize;	/* bytes/sector in hardware*/
 extern int64_t	fsize;		/* fragment size */
 extern int64_t	bsize;		/* block size */



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