aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2016-09-16 18:41:00 -0700
committerJaegeuk Kim <jaegeuk@kernel.org>2016-09-22 19:32:14 -0700
commit3ffc5a8f3ea0a70e247d1b1b222ad27f20716bdd (patch)
tree6107e1953b7b86f3dcd99d6adf28fb97924f39c2 /lib
parent79b1858e791c0d9ce6c4c693140e833023d74d42 (diff)
downloadandroid_external_f2fs-tools-3ffc5a8f3ea0a70e247d1b1b222ad27f20716bdd.tar.gz
android_external_f2fs-tools-3ffc5a8f3ea0a70e247d1b1b222ad27f20716bdd.tar.bz2
android_external_f2fs-tools-3ffc5a8f3ea0a70e247d1b1b222ad27f20716bdd.zip
f2fs-tools: use shorter config variable name
This patch has no functional change. Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libf2fs.c108
-rw-r--r--lib/libf2fs_io.c32
-rw-r--r--lib/zbc.c46
3 files changed, 93 insertions, 93 deletions
diff --git a/lib/libf2fs.c b/lib/libf2fs.c
index 706cc34..2284a78 100644
--- a/lib/libf2fs.c
+++ b/lib/libf2fs.c
@@ -487,24 +487,24 @@ int f2fs_crc_valid(u_int32_t blk_crc, void *buf, int len)
/*
* device information
*/
-void f2fs_init_configuration(struct f2fs_configuration *c)
+void f2fs_init_configuration(void)
{
- c->total_sectors = 0;
- c->sector_size = DEFAULT_SECTOR_SIZE;
- c->sectors_per_blk = DEFAULT_SECTORS_PER_BLOCK;
- c->blks_per_seg = DEFAULT_BLOCKS_PER_SEGMENT;
+ c.total_sectors = 0;
+ c.sector_size = DEFAULT_SECTOR_SIZE;
+ c.sectors_per_blk = DEFAULT_SECTORS_PER_BLOCK;
+ c.blks_per_seg = DEFAULT_BLOCKS_PER_SEGMENT;
/* calculated by overprovision ratio */
- c->reserved_segments = 0;
- c->overprovision = 0;
- c->segs_per_sec = 1;
- c->secs_per_zone = 1;
- c->segs_per_zone = 1;
- c->heap = 1;
- c->vol_label = "";
- c->device_name = NULL;
- c->trim = 1;
- c->ro = 0;
+ c.reserved_segments = 0;
+ c.overprovision = 0;
+ c.segs_per_sec = 1;
+ c.secs_per_zone = 1;
+ c.segs_per_zone = 1;
+ c.heap = 1;
+ c.vol_label = "";
+ c.device_name = NULL;
+ c.trim = 1;
+ c.ro = 0;
}
static int is_mounted(const char *mpt, const char *device)
@@ -520,7 +520,7 @@ static int is_mounted(const char *mpt, const char *device)
if (!strcmp(device, mnt->mnt_fsname)) {
#ifdef MNTOPT_RO
if (hasmntopt(mnt, MNTOPT_RO))
- config.ro = 1;
+ c.ro = 1;
#endif
break;
}
@@ -529,7 +529,7 @@ static int is_mounted(const char *mpt, const char *device)
return mnt ? 1 : 0;
}
-int f2fs_dev_is_umounted(struct f2fs_configuration *c)
+int f2fs_dev_is_umounted(void)
{
struct stat st_buf;
int ret = 0;
@@ -538,13 +538,13 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
* try with /proc/mounts fist to detect RDONLY.
* f2fs_stop_checkpoint makes RO in /proc/mounts while RW in /etc/mtab.
*/
- ret = is_mounted("/proc/mounts", c->device_name);
+ ret = is_mounted("/proc/mounts", c.device_name);
if (ret) {
MSG(0, "Info: Mounted device!\n");
return -1;
}
- ret = is_mounted(MOUNTED, c->device_name);
+ ret = is_mounted(MOUNTED, c.device_name);
if (ret) {
MSG(0, "Info: Mounted device!\n");
return -1;
@@ -554,8 +554,8 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
* If f2fs is umounted with -l, the process can still use
* the file system. In this case, we should not format.
*/
- if (stat(c->device_name, &st_buf) == 0 && S_ISBLK(st_buf.st_mode)) {
- int fd = open(c->device_name, O_RDONLY | O_EXCL);
+ if (stat(c.device_name, &st_buf) == 0 && S_ISBLK(st_buf.st_mode)) {
+ int fd = open(c.device_name, O_RDONLY | O_EXCL);
if (fd >= 0) {
close(fd);
@@ -577,7 +577,7 @@ void get_kernel_version(__u8 *version)
memset(version + i, 0, VERSION_LEN + 1 - i);
}
-int f2fs_get_device_info(struct f2fs_configuration *c)
+int f2fs_get_device_info(void)
{
int32_t fd = 0;
uint32_t sector_size;
@@ -589,17 +589,17 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
sg_io_hdr_t io_hdr;
unsigned char reply_buffer[96];
unsigned char model_inq[6] = {MODELINQUIRY};
- u_int64_t wanted_total_sectors = c->total_sectors;
+ u_int64_t wanted_total_sectors = c.total_sectors;
- fd = open(c->device_name, O_RDWR);
+ fd = open(c.device_name, O_RDWR);
if (fd < 0) {
MSG(0, "\tError: Failed to open the device!\n");
return -1;
}
- c->fd = fd;
+ c.fd = fd;
- c->kd = open("/proc/version", O_RDONLY);
- if (c->kd < 0)
+ c.kd = open("/proc/version", O_RDONLY);
+ if (c.kd < 0)
MSG(0, "\tInfo: No support kernel version!\n");
if (fstat(fd, &stat_buf) < 0 ) {
@@ -608,35 +608,35 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
}
if (S_ISREG(stat_buf.st_mode)) {
- c->total_sectors = stat_buf.st_size / c->sector_size;
+ c.total_sectors = stat_buf.st_size / c.sector_size;
} else if (S_ISBLK(stat_buf.st_mode)) {
if (ioctl(fd, BLKSSZGET, &sector_size) < 0) {
MSG(0, "\tError: Using the default sector size\n");
} else {
- if (c->sector_size < sector_size) {
- c->sector_size = sector_size;
- c->sectors_per_blk = PAGE_SIZE / sector_size;
+ if (c.sector_size < sector_size) {
+ c.sector_size = sector_size;
+ c.sectors_per_blk = PAGE_SIZE / sector_size;
}
}
#ifdef BLKGETSIZE64
- if (ioctl(fd, BLKGETSIZE64, &c->total_sectors) < 0) {
+ if (ioctl(fd, BLKGETSIZE64, &c.total_sectors) < 0) {
MSG(0, "\tError: Cannot get the device size\n");
return -1;
}
- c->total_sectors /= c->sector_size;
+ c.total_sectors /= c.sector_size;
#else
if (ioctl(fd, BLKGETSIZE, &total_sectors) < 0) {
MSG(0, "\tError: Cannot get the device size\n");
return -1;
}
- total_sectors /= c->sector_size;
- c->total_sectors = total_sectors;
+ total_sectors /= c.sector_size;
+ c.total_sectors = total_sectors;
#endif
if (ioctl(fd, HDIO_GETGEO, &geom) < 0)
- c->start_sector = 0;
+ c.start_sector = 0;
else
- c->start_sector = geom.start;
+ c.start_sector = geom.start;
/* Send INQUIRY command */
memset(&io_hdr, 0, sizeof(sg_io_hdr_t));
@@ -660,37 +660,37 @@ int f2fs_get_device_info(struct f2fs_configuration *c)
MSG(0, "\tError: Volume type is not supported!!!\n");
return -1;
}
- if (wanted_total_sectors && wanted_total_sectors < c->total_sectors) {
+ if (wanted_total_sectors && wanted_total_sectors < c.total_sectors) {
MSG(0, "Info: total device sectors = %"PRIu64" (in %u bytes)\n",
- c->total_sectors, c->sector_size);
- c->total_sectors = wanted_total_sectors;
+ c.total_sectors, c.sector_size);
+ c.total_sectors = wanted_total_sectors;
}
- if (c->total_sectors * c->sector_size >
+ if (c.total_sectors * c.sector_size >
(u_int64_t)F2FS_MAX_SEGMENT * 2 * 1024 * 1024) {
MSG(0, "\tError: F2FS can support 16TB at most!!!\n");
return -1;
}
- if (config.smr_mode) {
- if (zbc_scsi_report_zones(c)) {
+ if (c.smr_mode) {
+ if (zbc_scsi_report_zones()) {
MSG(0, "\tError: Not proper SMR drive\n");
return -1;
}
MSG(0, "Info: SMR - ZONES = %u, CONV = %u, ZONE_SECTS = %lu\n",
- c->nr_zones, c->nr_conventional,
- c->zone_sectors);
- if (c->segs_per_sec == 1)
- c->segs_per_sec = c->zone_sectors /
- c->sectors_per_blk / DEFAULT_BLOCKS_PER_SEGMENT;
+ c.nr_zones, c.nr_conventional,
+ c.zone_sectors);
+ if (c.segs_per_sec == 1)
+ c.segs_per_sec = c.zone_sectors /
+ c.sectors_per_blk / DEFAULT_BLOCKS_PER_SEGMENT;
}
- c->segs_per_zone = c->segs_per_sec * c->secs_per_zone;
+ c.segs_per_zone = c.segs_per_sec * c.secs_per_zone;
- MSG(0, "Info: Segments per section = %d\n", config.segs_per_sec);
- MSG(0, "Info: Sections per zone = %d\n", config.secs_per_zone);
- MSG(0, "Info: sector size = %u\n", c->sector_size);
+ MSG(0, "Info: Segments per section = %d\n", c.segs_per_sec);
+ MSG(0, "Info: Sections per zone = %d\n", c.secs_per_zone);
+ MSG(0, "Info: sector size = %u\n", c.sector_size);
MSG(0, "Info: total sectors = %"PRIu64" (%"PRIu64" MB)\n",
- c->total_sectors, (c->total_sectors *
- (c->sector_size >> 9)) >> 11);
+ c.total_sectors, (c.total_sectors *
+ (c.sector_size >> 9)) >> 11);
return 0;
}
diff --git a/lib/libf2fs_io.c b/lib/libf2fs_io.c
index d2a04b2..1817c15 100644
--- a/lib/libf2fs_io.c
+++ b/lib/libf2fs_io.c
@@ -23,25 +23,25 @@
#include <f2fs_fs.h>
-struct f2fs_configuration config;
+struct f2fs_configuration c;
/*
* IO interfaces
*/
int dev_read_version(void *buf, __u64 offset, size_t len)
{
- if (lseek64(config.kd, (off64_t)offset, SEEK_SET) < 0)
+ if (lseek64(c.kd, (off64_t)offset, SEEK_SET) < 0)
return -1;
- if (read(config.kd, buf, len) < 0)
+ if (read(c.kd, buf, len) < 0)
return -1;
return 0;
}
int dev_read(void *buf, __u64 offset, size_t len)
{
- if (lseek64(config.fd, (off64_t)offset, SEEK_SET) < 0)
+ if (lseek64(c.fd, (off64_t)offset, SEEK_SET) < 0)
return -1;
- if (read(config.fd, buf, len) < 0)
+ if (read(c.fd, buf, len) < 0)
return -1;
return 0;
}
@@ -49,7 +49,7 @@ int dev_read(void *buf, __u64 offset, size_t len)
int dev_readahead(__u64 offset, size_t len)
{
#ifdef POSIX_FADV_WILLNEED
- return posix_fadvise(config.fd, offset, len, POSIX_FADV_WILLNEED);
+ return posix_fadvise(c.fd, offset, len, POSIX_FADV_WILLNEED);
#else
return 0;
#endif
@@ -57,9 +57,9 @@ int dev_readahead(__u64 offset, size_t len)
int dev_write(void *buf, __u64 offset, size_t len)
{
- if (lseek64(config.fd, (off64_t)offset, SEEK_SET) < 0)
+ if (lseek64(c.fd, (off64_t)offset, SEEK_SET) < 0)
return -1;
- if (write(config.fd, buf, len) < 0)
+ if (write(c.fd, buf, len) < 0)
return -1;
return 0;
}
@@ -71,9 +71,9 @@ int dev_write_block(void *buf, __u64 blk_addr)
int dev_write_dump(void *buf, __u64 offset, size_t len)
{
- if (lseek64(config.dump_fd, (off64_t)offset, SEEK_SET) < 0)
+ if (lseek64(c.dump_fd, (off64_t)offset, SEEK_SET) < 0)
return -1;
- if (write(config.dump_fd, buf, len) < 0)
+ if (write(c.dump_fd, buf, len) < 0)
return -1;
return 0;
}
@@ -83,9 +83,9 @@ int dev_fill(void *buf, __u64 offset, size_t len)
/* Only allow fill to zero */
if (*((__u8*)buf))
return -1;
- if (lseek64(config.fd, (off64_t)offset, SEEK_SET) < 0)
+ if (lseek64(c.fd, (off64_t)offset, SEEK_SET) < 0)
return -1;
- if (write(config.fd, buf, len) < 0)
+ if (write(c.fd, buf, len) < 0)
return -1;
return 0;
}
@@ -105,17 +105,17 @@ int dev_reada_block(__u64 blk_addr)
return dev_readahead(blk_addr << F2FS_BLKSIZE_BITS, F2FS_BLKSIZE);
}
-void f2fs_finalize_device(struct f2fs_configuration *c)
+void f2fs_finalize_device(void)
{
/*
* We should call fsync() to flush out all the dirty pages
* in the block device page cache.
*/
- if (fsync(c->fd) < 0)
+ if (fsync(c.fd) < 0)
MSG(0, "\tError: Could not conduct fsync!!!\n");
- if (close(c->fd) < 0)
+ if (close(c.fd) < 0)
MSG(0, "\tError: Failed to close device file!!!\n");
- close(c->kd);
+ close(c.kd);
}
diff --git a/lib/zbc.c b/lib/zbc.c
index 6ec2fc7..1783bd5 100644
--- a/lib/zbc.c
+++ b/lib/zbc.c
@@ -324,42 +324,42 @@ static char *zbc_sg_cmd_name(zbc_sg_cmd_t *cmd)
return name;
}
-static void zbc_sg_set_sense(struct f2fs_configuration *c, uint8_t *sense_buf)
+static void zbc_sg_set_sense(uint8_t *sense_buf)
{
if (sense_buf == NULL) {
- c->zbd_errno.sk = 0x00;
- c->zbd_errno.asc_ascq = 0x0000;
+ c.zbd_errno.sk = 0x00;
+ c.zbd_errno.asc_ascq = 0x0000;
} else {
if ((sense_buf[0] & 0x7F) == 0x72
|| (sense_buf[0] & 0x7F) == 0x73) {
/* store sense key, ASC/ASCQ */
- c->zbd_errno.sk = sense_buf[1] & 0x0F;
- c->zbd_errno.asc_ascq = ((int)sense_buf[2] << 8) |
+ c.zbd_errno.sk = sense_buf[1] & 0x0F;
+ c.zbd_errno.asc_ascq = ((int)sense_buf[2] << 8) |
(int)sense_buf[3];
} else if ((sense_buf[0] & 0x7F) == 0x70
|| (sense_buf[0] & 0x7F) == 0x71) {
/* store sense key, ASC/ASCQ */
- c->zbd_errno.sk = sense_buf[2] & 0x0F;
- c->zbd_errno.asc_ascq = ((int)sense_buf[12] << 8) |
+ c.zbd_errno.sk = sense_buf[2] & 0x0F;
+ c.zbd_errno.asc_ascq = ((int)sense_buf[12] << 8) |
(int)sense_buf[13];
}
}
return;
}
-static int zbc_sg_cmd_exec(struct f2fs_configuration *c, zbc_sg_cmd_t *cmd)
+static int zbc_sg_cmd_exec(zbc_sg_cmd_t *cmd)
{
int ret;
/* Send the SG_IO command */
- ret = ioctl(c->fd, SG_IO, &cmd->io_hdr);
+ ret = ioctl(c.fd, SG_IO, &cmd->io_hdr);
if (ret) {
ERR_MSG("SG_IO ioctl failed (%s)\n", strerror(errno));
goto out;
}
/* Reset errno */
- zbc_sg_set_sense(c, NULL);
+ zbc_sg_set_sense(NULL);
DBG(1, "Command %s done: status 0x%02x (0x%02x), host status 0x%04x, driver status 0x%04x (flags 0x%04x)\n",
zbc_sg_cmd_name(cmd),
@@ -375,7 +375,7 @@ static int zbc_sg_cmd_exec(struct f2fs_configuration *c, zbc_sg_cmd_t *cmd)
/* ATA command status */
if (cmd->io_hdr.status != ZBC_SG_CHECK_CONDITION) {
- zbc_sg_set_sense(c, cmd->sense_buf);
+ zbc_sg_set_sense(cmd->sense_buf);
ret = -EIO;
goto out;
}
@@ -383,7 +383,7 @@ static int zbc_sg_cmd_exec(struct f2fs_configuration *c, zbc_sg_cmd_t *cmd)
if ((zbc_sg_cmd_driver_status(cmd) == ZBC_SG_DRIVER_SENSE)
&& (cmd->io_hdr.sb_len_wr > 21)
&& (cmd->sense_buf[21] != 0x50) ) {
- zbc_sg_set_sense(c, cmd->sense_buf);
+ zbc_sg_set_sense(cmd->sense_buf);
ret = -EIO;
goto out;
}
@@ -402,7 +402,7 @@ static int zbc_sg_cmd_exec(struct f2fs_configuration *c, zbc_sg_cmd_t *cmd)
(unsigned int)cmd->io_hdr.host_status,
(unsigned int)zbc_sg_cmd_driver_status(cmd),
(unsigned int)zbc_sg_cmd_driver_flags(cmd));
- zbc_sg_set_sense(c, cmd->sense_buf);
+ zbc_sg_set_sense(cmd->sense_buf);
ret = -EIO;
goto out;
}
@@ -418,7 +418,7 @@ out:
#define ZBC_SCSI_REPORT_ZONES_BUFSZ 524288
-int zbc_scsi_report_zones(struct f2fs_configuration *c)
+int zbc_scsi_report_zones(void)
{
zbc_sg_cmd_t cmd;
uint8_t *buf;
@@ -431,10 +431,10 @@ int zbc_scsi_report_zones(struct f2fs_configuration *c)
next:
bufsz = ZBC_ZONE_DESCRIPTOR_OFFSET;
if (phase) {
- if (c->nr_zones - idx == 0)
+ if (c.nr_zones - idx == 0)
return 0;
- bufsz += (size_t)(c->nr_zones - idx) *
+ bufsz += (size_t)(c.nr_zones - idx) *
ZBC_ZONE_DESCRIPTOR_LENGTH;
if (bufsz > ZBC_SCSI_REPORT_ZONES_BUFSZ)
bufsz = ZBC_SCSI_REPORT_ZONES_BUFSZ;
@@ -479,7 +479,7 @@ next:
cmd.cdb[14] = 0;
/* Send the SG_IO command */
- ret = zbc_sg_cmd_exec(c, &cmd);
+ ret = zbc_sg_cmd_exec(&cmd);
if (ret != 0)
goto out;
@@ -536,15 +536,15 @@ next:
/* read # of zones and then get all the zone info */
if (phase == 0) {
- c->nr_zones = nr_zones;
- c->nr_conventional = 0;
+ c.nr_zones = nr_zones;
+ c.nr_conventional = 0;
zbc_sg_cmd_destroy(&cmd);
phase++;
goto next;
}
- if (nr_zones > c->nr_zones - idx)
- nr_zones = c->nr_zones - idx;
+ if (nr_zones > c.nr_zones - idx)
+ nr_zones = c.nr_zones - idx;
buf_nz = (cmd.out_bufsz - ZBC_ZONE_DESCRIPTOR_OFFSET) /
ZBC_ZONE_DESCRIPTOR_LENGTH;
@@ -610,7 +610,7 @@ next:
for (i = 0; i < nr_zones; i++) {
z = &zones[i];
if ( zbc_zone_conventional(z) ) {
- c->nr_conventional++;
+ c.nr_conventional++;
DBG(1, "Zone %05d: type 0x%x (%s), cond 0x%x (%s), LBA %llu, %llu sectors, wp N/A\n",
i + idx,
zbc_zone_type(z),
@@ -636,7 +636,7 @@ next:
idx += nr_zones;
next_lba = zones[nr_zones - 1].zbz_start + zones[nr_zones - 1].zbz_length;
- c->zone_sectors = zones[nr_zones - 1].zbz_length;
+ c.zone_sectors = zones[nr_zones - 1].zbz_length;
phase++;
zbc_sg_cmd_destroy(&cmd);
free(zones);