lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080820173406.23412.49918.stgit@gara>
Date:	Wed, 20 Aug 2008 12:34:07 -0500
From:	"Jose R. Santos" <jrs@...ibm.com>
To:	"Theodore Ts'o" <tytso@....edu>, linux-ext4@...r.kernel.org
Subject: [PATCH 13/15][e2fsprogs] Add 64-bit getsize interface.

From: Jose R. Santos <jrs@...ibm.com>

Add 64-bit getsize interface.

Added interface capable of opening 64-bit block device.

Signed-off-by: Jose R. Santos <jrs@...ibm.com>
--

 lib/ext2fs/ext2fs.h  |    2 ++
 lib/ext2fs/getsize.c |   38 ++++++++++++++++----------------------
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/lib/ext2fs/ext2fs.h b/lib/ext2fs/ext2fs.h
index 99c2c5f..8703b79 100644
--- a/lib/ext2fs/ext2fs.h
+++ b/lib/ext2fs/ext2fs.h
@@ -985,6 +985,8 @@ extern errcode_t ext2fs_set_generic_bitmap_range(ext2fs_generic_bitmap bmap,
 /* getsize.c */
 extern errcode_t ext2fs_get_device_size(const char *file, int blocksize,
 					blk_t *retblocks);
+extern errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
+					blk64_t *retblocks);
 
 /* getsectsize.c */
 errcode_t ext2fs_get_device_sectsize(const char *file, int *sectsize);
diff --git a/lib/ext2fs/getsize.c b/lib/ext2fs/getsize.c
index 7f6ef71..dd460a1 100644
--- a/lib/ext2fs/getsize.c
+++ b/lib/ext2fs/getsize.c
@@ -138,8 +138,8 @@ static int valid_offset (int fd, ext2_loff_t offset)
 /*
  * Returns the number of blocks in a partition
  */
-errcode_t ext2fs_get_device_size(const char *file, int blocksize,
-				 blk_t *retblocks)
+errcode_t ext2fs_get_device_size2(const char *file, int blocksize,
+				 blk64_t *retblocks)
 {
 	int	fd, rc = 0;
 	int valid_blkgetsize64 = 1;
@@ -169,11 +169,6 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
 
 #ifdef DKIOCGETBLOCKCOUNT	/* For Apple Darwin */
 	if (ioctl(fd, DKIOCGETBLOCKCOUNT, &size64) >= 0) {
-		if ((sizeof(*retblocks) < sizeof(unsigned long long))
-		    && ((size64 / (blocksize / 512)) > 0xFFFFFFFF)) {
-			rc = EFBIG;
-			goto out;
-		}
 		*retblocks = size64 / (blocksize / 512);
 		goto out;
 	}
@@ -188,11 +183,6 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
 #endif
 	if (valid_blkgetsize64 &&
 	    ioctl(fd, BLKGETSIZE64, &size64) >= 0) {
-		if ((sizeof(*retblocks) < sizeof(unsigned long long)) &&
-		    ((size64 / blocksize) > 0xFFFFFFFF)) {
-			rc = EFBIG;
-			goto out;
-		}
 		*retblocks = size64 / blocksize;
 		goto out;
 	}
@@ -253,11 +243,6 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
 		if (fstat(fd, &st) == 0)
 #endif
 			if (S_ISREG(st.st_mode)) {
-				if ((sizeof(*retblocks) < sizeof(unsigned long long)) &&
-				    ((st.st_size / blocksize) > 0xFFFFFFFF)) {
-					rc = EFBIG;
-					goto out;
-				}
 				*retblocks = st.st_size / blocksize;
 				goto out;
 			}
@@ -282,17 +267,26 @@ errcode_t ext2fs_get_device_size(const char *file, int blocksize,
 	}
 	valid_offset (fd, 0);
 	size64 = low + 1;
-	if ((sizeof(*retblocks) < sizeof(unsigned long long))
-	    && ((size64 / blocksize) > 0xFFFFFFFF)) {
-		rc = EFBIG;
-		goto out;
-	}
 	*retblocks = size64 / blocksize;
 out:
 	close(fd);
 	return rc;
 }
 
+errcode_t ext2fs_get_device_size(const char *file, int blocksize,
+				 blk_t *retblocks)
+{
+	errcode_t retval;
+	blk64_t	blocks;
+	retval = ext2fs_get_device_size2(file, blocksize, &blocks);
+
+	if (!retval && blocks < (1ULL << 32)) {
+		*retblocks = (blk_t) blocks;
+		return retval;
+	}
+	return EFBIG;
+}
+
 #endif /* WIN32 */
 
 #ifdef DEBUG

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ