From patchwork Wed Jul 15 20:11:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 1329787 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B6T7X2Ty8z9sRk for ; Thu, 16 Jul 2020 06:12:08 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 34D4881BC5; Wed, 15 Jul 2020 22:11:58 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 93BFF81B65; Wed, 15 Jul 2020 22:11:52 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 08CC281B65 for ; Wed, 15 Jul 2020 22:11:50 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=thomas.petazzoni@bootlin.com X-Originating-IP: 90.30.52.66 Received: from localhost (lfbn-bay-1-589-66.w90-30.abo.wanadoo.fr [90.30.52.66]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 39755C0002; Wed, 15 Jul 2020 20:11:49 +0000 (UTC) From: Thomas Petazzoni To: Joao Marcos Costa Cc: u-boot@lists.denx.de, miquel.raynal@bootlin.com, Thomas Petazzoni Subject: [PATCH 1/3] cmd/sqfs.c, include/fs.h: fix build failures, don't expose do_sqfs_*() functions globally Date: Wed, 15 Jul 2020 22:11:41 +0200 Message-Id: <20200715201143.2168632-2-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200715201143.2168632-1-thomas.petazzoni@bootlin.com> References: <20200709175148.17193-1-joaomarcos.costa@bootlin.com> <20200715201143.2168632-1-thomas.petazzoni@bootlin.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean The cmd_tbl_t type has been removed upstream since commit 09140113108 ("command: Remove the cmd_tbl_t typedef"), so we must use "struct cmd_tbl" instead. The include was missing in cmd/sqfs.c, without which U_BOOT_CMD() is not defined. Finally, there is no reason to globally expose do_sqfs_ls() and do_sqfs_load(), they are only used within cmd/sqfs.c. This allows to drop the do_sqfs_load() prototype from include/fs.h. Signed-off-by: Thomas Petazzoni --- cmd/sqfs.c | 5 +++-- include/fs.h | 12 ------------ 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/cmd/sqfs.c b/cmd/sqfs.c index af42df728b..177008e802 100644 --- a/cmd/sqfs.c +++ b/cmd/sqfs.c @@ -7,10 +7,11 @@ * squashfs.c: implements SquashFS related commands */ +#include #include #include -int do_sqfs_ls(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_sqfs_ls(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { return do_ls(cmdtp, flag, argc, argv, FS_TYPE_SQUASHFS); } @@ -22,7 +23,7 @@ U_BOOT_CMD( " - list files from 'dev' on 'interface' in 'directory'\n" ); -int do_sqfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) +static int do_sqfs_load(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv[]) { return do_load(cmdtp, flag, argc, argv, FS_TYPE_SQUASHFS); } diff --git a/include/fs.h b/include/fs.h index 19f4afc482..0794b50d10 100644 --- a/include/fs.h +++ b/include/fs.h @@ -42,18 +42,6 @@ int do_fat_fsload(struct cmd_tbl *cmdtp, int flag, int argc, */ int do_ext2load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); - -/** - * do_sqfs_load - Run the sqfsload command - * - * @cmdtp: Command information for sqfsload - * @flag: Command flags (CMD_FLAG_...) - * @argc: Number of arguments - * @argv: List of arguments - * @return result (see enum command_ret_t) - */ -int do_sqfs_load(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]); - /* * Tell the fs layer which block device an partition to use for future * commands. This also internally identifies the filesystem that is present From patchwork Wed Jul 15 20:11:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 1329788 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B6T7m0nfsz9sRk for ; Thu, 16 Jul 2020 06:12:20 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E830281BEC; Wed, 15 Jul 2020 22:12:00 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 6DCCF81B6E; Wed, 15 Jul 2020 22:11:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 3795E81B6E for ; Wed, 15 Jul 2020 22:11:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=thomas.petazzoni@bootlin.com X-Originating-IP: 90.30.52.66 Received: from localhost (lfbn-bay-1-589-66.w90-30.abo.wanadoo.fr [90.30.52.66]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 455C820002; Wed, 15 Jul 2020 20:11:50 +0000 (UTC) From: Thomas Petazzoni To: Joao Marcos Costa Cc: u-boot@lists.denx.de, miquel.raynal@bootlin.com, Thomas Petazzoni Subject: [PATCH 2/3] fs/squashfs: use "struct disk_partition" instead of "disk_partition_t" Date: Wed, 15 Jul 2020 22:11:42 +0200 Message-Id: <20200715201143.2168632-3-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200715201143.2168632-1-thomas.petazzoni@bootlin.com> References: <20200709175148.17193-1-joaomarcos.costa@bootlin.com> <20200715201143.2168632-1-thomas.petazzoni@bootlin.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean disk_partition_t was dropped in 0528979fa7ab ("part: Drop disk_partition_t typedef"). Signed-off-by: Thomas Petazzoni --- fs/squashfs/sqfs.c | 5 +++-- include/squashfs.h | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 3302a63cca..8d43564b50 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -17,12 +17,13 @@ #include #include #include +#include #include "sqfs_decompressor.h" #include "sqfs_filesystem.h" #include "sqfs_utils.h" -static disk_partition_t cur_part_info; +static struct disk_partition cur_part_info; static struct blk_desc *cur_dev; static int sqfs_disk_read(__u32 block, __u32 nr_blocks, void *buf) @@ -1013,7 +1014,7 @@ int sqfs_readdir(struct fs_dir_stream *fs_dirs, struct fs_dirent **dentp) return SQFS_CONTINUE_READDIR; } -int sqfs_probe(struct blk_desc *fs_dev_desc, disk_partition_t *fs_partition) +int sqfs_probe(struct blk_desc *fs_dev_desc, struct disk_partition *fs_partition) { struct squashfs_super_block *sblk; diff --git a/include/squashfs.h b/include/squashfs.h index ec59eee8d8..4dd390d8b6 100644 --- a/include/squashfs.h +++ b/include/squashfs.h @@ -10,11 +10,13 @@ #ifndef _SQFS_H_ #define _SQFS_H_ +struct disk_partition; + int sqfs_opendir(const char *filename, struct fs_dir_stream **dirsp); int sqfs_ls(const char *filename); int sqfs_readdir(struct fs_dir_stream *dirs, struct fs_dirent **dentp); int sqfs_probe(struct blk_desc *fs_dev_desc, - disk_partition_t *fs_partition); + struct disk_partition *fs_partition); int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, loff_t *actread); int sqfs_size(const char *filename, loff_t *size); From patchwork Wed Jul 15 20:11:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Petazzoni X-Patchwork-Id: 1329793 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bootlin.com Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4B6T7z5fw1z9sSn for ; Thu, 16 Jul 2020 06:12:31 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A2DA481BD0; Wed, 15 Jul 2020 22:12:04 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 287AF81BA2; Wed, 15 Jul 2020 22:11:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E8FD5819EA for ; Wed, 15 Jul 2020 22:11:51 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=thomas.petazzoni@bootlin.com X-Originating-IP: 90.30.52.66 Received: from localhost (lfbn-bay-1-589-66.w90-30.abo.wanadoo.fr [90.30.52.66]) (Authenticated sender: thomas.petazzoni@bootlin.com) by relay6-d.mail.gandi.net (Postfix) with ESMTPSA id 3D755C0002; Wed, 15 Jul 2020 20:11:51 +0000 (UTC) From: Thomas Petazzoni To: Joao Marcos Costa Cc: u-boot@lists.denx.de, miquel.raynal@bootlin.com, Thomas Petazzoni Subject: [PATCH 3/3] fs/squashfs: do not use CMD_RET_* defines in the filesystem code Date: Wed, 15 Jul 2020 22:11:43 +0200 Message-Id: <20200715201143.2168632-4-thomas.petazzoni@bootlin.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200715201143.2168632-1-thomas.petazzoni@bootlin.com> References: <20200709175148.17193-1-joaomarcos.costa@bootlin.com> <20200715201143.2168632-1-thomas.petazzoni@bootlin.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Using CMD_RET_* defines in fs/squashfs/ breaks the build as they are not defined. These defines are really meant to be used as return values of commands, not internally in filesystem code. Instead, appropriate errno codes should be used. This patch changes fs/squashfs to use proper errno code. In most places, it is straightforward. There are a few places where it is not: - In sqfs_read(), the value of datablk_count was checked *after* it was used to do a memcpy(). So the memcpy() could have used a negative size. The check was moved prior to the memcpy(), right after calling sqfs_get_regfile_info() and sqfs_get_lregfile_info(). - The sqfs_size() function is modified to return "ret" at the end, so that the error code is properly propagated. Signed-off-by: Thomas Petazzoni --- fs/squashfs/sqfs.c | 61 +++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 36 deletions(-) diff --git a/fs/squashfs/sqfs.c b/fs/squashfs/sqfs.c index 8d43564b50..27f0b33a92 100644 --- a/fs/squashfs/sqfs.c +++ b/fs/squashfs/sqfs.c @@ -1241,10 +1241,8 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, */ sqfs_split_path(&file, &dir, filename); ret = sqfs_opendir(dir, &dirs.fs_dirs); - if (ret) { - ret = CMD_RET_FAILURE; + if (ret) goto free_paths; - } dirsp = (struct fs_dir_stream *)&dirs; dirs.dentp = &dent; @@ -1253,7 +1251,6 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, if (!strncmp(dent.name, file, strlen(dent.name))) { ret = sqfs_read_entry(&entry, dirs.entry); if (ret) { - ret = CMD_RET_FAILURE; free(dirs.entry); sqfs_closedir(dirsp); goto free_paths; @@ -1269,7 +1266,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, printf("File not found.\n"); *actread = 0; sqfs_closedir(dirsp); - ret = CMD_RET_FAILURE; + ret = -ENOENT; goto free_paths; } @@ -1283,6 +1280,10 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, memcpy(®, ipos, sizeof(reg)); datablk_count = sqfs_get_regfile_info(®, &finfo, &frag_entry, sblk->block_size); + if (datablk_count < 0) { + ret = -EINVAL; + goto free_entry; + } memcpy(finfo.blk_sizes, ipos + sizeof(reg), datablk_count * sizeof(u32)); break; @@ -1291,6 +1292,10 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, datablk_count = sqfs_get_lregfile_info(&lreg, &finfo, &frag_entry, sblk->block_size); + if (datablk_count < 0) { + ret = -EINVAL; + goto free_entry; + } memcpy(finfo.blk_sizes, ipos + sizeof(lreg), datablk_count * sizeof(u32)); break; @@ -1301,9 +1306,6 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, printf("%s - > %s\n", filename, resolved); ret = sqfs_read(resolved, buf, offset, len, actread); free(resolved); - if (ret) - ret = CMD_RET_FAILURE; - ret = CMD_RET_SUCCESS; goto free_entry; case SQFS_BLKDEV_TYPE: case SQFS_CHRDEV_TYPE: @@ -1315,19 +1317,14 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, case SQFS_LSOCKET_TYPE: default: printf("Unsupported entry type\n"); - ret = CMD_RET_FAILURE; - goto free_entry; - } - - if (datablk_count < 0) { - ret = CMD_RET_FAILURE; + ret = -EINVAL; goto free_entry; } /* If the user specifies a length, check its sanity */ if (len) { if (len > finfo.size) { - ret = CMD_RET_FAILURE; + ret = -EINVAL; goto free_entry; } @@ -1338,7 +1335,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, data_offset = finfo.start; datablock = malloc(sblk->block_size); if (!datablock) { - ret = CMD_RET_FAILURE; + ret = -ENOMEM; goto free_entry; } } @@ -1353,18 +1350,18 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, data_buffer = malloc_cache_aligned(n_blks * cur_dev->blksz); if (!data_buffer) { - ret = CMD_RET_FAILURE; + ret = -ENOMEM; goto free_datablk; } - if (sqfs_disk_read(start, n_blks, data_buffer) < 0) { + ret = sqfs_disk_read(start, n_blks, data_buffer); + if (ret < 0) { /* * Tip: re-compile the SquashFS image with mksquashfs's * -b option. */ printf("Error: too many data blocks or too large"\ "SquashFS block size.\n"); - ret = CMD_RET_FAILURE; goto free_buffer; } @@ -1375,10 +1372,8 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, dest_len = sblk->block_size; ret = sqfs_decompress(comp_type, datablock, &dest_len, data, table_size); - if (ret) { - ret = CMD_RET_FAILURE; + if (ret) goto free_buffer; - } memcpy(buf + offset + *actread, datablock, dest_len); *actread += dest_len; @@ -1396,7 +1391,7 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, * There is no need to continue if the file is not fragmented. */ if (!finfo.frag) { - ret = CMD_RET_SUCCESS; + ret = 0; goto free_buffer; } @@ -1408,21 +1403,20 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, fragment = malloc_cache_aligned(n_blks * cur_dev->blksz); if (!fragment) { - ret = CMD_RET_FAILURE; + ret = -ENOMEM; goto free_buffer; } - if (sqfs_disk_read(start, n_blks, fragment) < 0) { - ret = CMD_RET_FAILURE; + ret = sqfs_disk_read(start, n_blks, fragment); + if (ret < 0) goto free_fragment; - } /* File compressed and fragmented */ if (finfo.frag && finfo.comp) { dest_len = sblk->block_size; fragment_block = malloc(sblk->block_size); if (!fragment_block) { - ret = CMD_RET_FAILURE; + ret = -ENOMEM; goto free_fragment; } @@ -1431,7 +1425,6 @@ int sqfs_read(const char *filename, void *buf, loff_t offset, loff_t len, frag_entry.size); if (ret) { free(fragment_block); - ret = CMD_RET_FAILURE; goto free_fragment; } @@ -1480,7 +1473,7 @@ int sqfs_ls(const char *filename) ret = sqfs_opendir(filename, &dirs.fs_dirs); if (ret) { sqfs_closedir(dirsp); - return CMD_RET_FAILURE; + return ret; } dirs.dentp = &dent; @@ -1542,7 +1535,6 @@ int sqfs_size(const char *filename, loff_t *size) ret = sqfs_opendir(dir, &dirs.fs_dirs); if (ret) { sqfs_closedir(dirsp); - ret = CMD_RET_FAILURE; goto free_strings; } @@ -1558,7 +1550,6 @@ int sqfs_size(const char *filename, loff_t *size) if (ret) { sqfs_closedir(dirsp); - ret = CMD_RET_FAILURE; goto free_strings; } @@ -1583,9 +1574,6 @@ int sqfs_size(const char *filename, loff_t *size) resolved = sqfs_resolve_symlink(&symlink, ipos, filename); ret = sqfs_size(resolved, size); free(resolved); - if (ret) - ret = CMD_RET_FAILURE; - ret = CMD_RET_SUCCESS; break; case SQFS_BLKDEV_TYPE: case SQFS_CHRDEV_TYPE: @@ -1598,6 +1586,7 @@ int sqfs_size(const char *filename, loff_t *size) default: printf("Unable to recover entry's size.\n"); *size = 0; + ret = -EINVAL; break; } @@ -1608,7 +1597,7 @@ free_strings: free(sblk); sqfs_closedir(dirsp); - return 0; + return ret; } void sqfs_close(void)