Re: [PATCH] xfs_io: Make copy_range arguments understand *iB values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/10/18 7:22 PM, Goldwyn Rodrigues wrote:
Arguments such as 2MiB or 2M are converted to 2 because copy_range uses
strtoull(). Convert strtoull() to cvtnum().

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>


Thanks

Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>


diff --git a/io/copy_file_range.c b/io/copy_file_range.c
index 99fba20a..0cf658e1 100644
--- a/io/copy_file_range.c
+++ b/io/copy_file_range.c
@@ -47,7 +47,7 @@ copy_range_help(void)
   * glibc buffered copy fallback.
   */
  static loff_t
-copy_file_range_cmd(int fd, loff_t *src, loff_t *dst, size_t len)
+copy_file_range_cmd(int fd, long long *src, long long *dst, long long len)
  {
  	loff_t ret;
@@ -89,34 +89,36 @@ copy_dst_truncate(void)
  static int
  copy_range_f(int argc, char **argv)
  {
-	loff_t src = 0;
-	loff_t dst = 0;
+	long long src = 0;
+	long long dst = 0;
  	size_t len = 0;
-	char *sp;
  	int opt;
  	int ret;
  	int fd;
+	size_t fsblocksize, fssectsize;
+
+	init_cvtnum(&fsblocksize, &fssectsize);
while ((opt = getopt(argc, argv, "s:d:l:")) != -1) {
  		switch (opt) {
  		case 's':
-			src = strtoull(optarg, &sp, 10);
-			if (!sp || sp == optarg) {
-				printf(_("invalid source offset -- %s\n"), sp);
+			src = cvtnum(fsblocksize, fssectsize, optarg);
+			if (src < 0) {
+				printf(_("invalid source offset -- %s\n"), optarg);
  				return 0;
  			}
  			break;
  		case 'd':
-			dst = strtoull(optarg, &sp, 10);
-			if (!sp || sp == optarg) {
-				printf(_("invalid destination offset -- %s\n"), sp);
+			dst = cvtnum(fsblocksize, fssectsize, optarg);
+			if (dst < 0) {
+				printf(_("invalid destination offset -- %s\n"), optarg);
  				return 0;
  			}
  			break;
  		case 'l':
-			len = strtoull(optarg, &sp, 10);
-			if (!sp || sp == optarg) {
-				printf(_("invalid length -- %s\n"), sp);
+			len = cvtnum(fsblocksize, fssectsize, optarg);
+			if (len < 0) {
+				printf(_("invalid length -- %s\n"), optarg);
  				return 0;
  			}
  			break;
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux