From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Fri, 28 Sep 2012 20:22:14 +0200 Subject: [U-Boot] [PATCH v6 1/2] Loop block device for sandbox In-Reply-To: <1348824089-17324-1-git-send-email-morpheus.ibis@gmail.com> References: <1347796706-15608-1-git-send-email-morpheus.ibis@gmail.com> <1348824089-17324-1-git-send-email-morpheus.ibis@gmail.com> Message-ID: <201209282022.14935.marex@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Pavel Herrmann, > This driver uses files as block devices, can be used for testing disk > operations on sandbox. > A new command "sata_loop" is introduced to load files in runtime. The description might use a little bit of caressing here :) [...] > + if (os_lseek(fd, start_byte, OS_SEEK_SET) != start_byte) > + return -1; Use errno consistently ... so -EINVAL ? Or something else? > + retval = os_read(fd, buffer, length_byte); > + > + return retval / ATA_SECT_SIZE; > +} [...] > + if (!strncmp(argv[1], "load", 4)) { if (strncmp()) return CMD_USAGE; one indent less here ;-) > + dev = simple_strtoul(argv[2], NULL, 10); > + /* > + * init_sata() and scan_sata() do their own range > + * check, however we need to explicitly do it here > + * as well. > + */ > + if (range_check(dev)) { > + printf("File index %d is out of range.\n", dev); > + return -EINVAL; > + } > + free(filenames[dev]); > + filenames[dev] = strdup(argv[3]); > + init_sata(dev); > + scan_sata(dev); > + /* > + * Scan the partition table if we succeeded in loading > + * the new loop file. > + */ > + if (sata_dev_desc[dev].lba > 0) > + init_part(&sata_dev_desc[dev]); > + > + return 0; > + } > + return CMD_RET_USAGE; > + } > + return CMD_RET_USAGE; > +} > + > +U_BOOT_CMD( > + sata_loop, 4, 1, do_loop, > + "SATA loopback", > + "info - show info about all loop devices\n" > + "sata_loop info devnum - show info about loop devnum\n" > + "sata_loop load devnum file - load file from host FS into loop devnum" > +);