int fs_mgr_do_format(struct fstab_rec *fstab, bool crypt_footer) { int rc = -EINVAL; ERROR("%s: Format %s as '%s'.\n", __func__, fstab->blk_device, fstab->fs_type); if (!strncmp(fstab->fs_type, "f2fs", 4)) { rc = format_f2fs(fstab->blk_device); } else if (!strncmp(fstab->fs_type, "ext4", 4)) { rc = format_ext4(fstab->blk_device, fstab->mount_point, crypt_footer); } else { ERROR("File system type '%s' is not supported\n", fstab->fs_type); } return rc; }
int fs_mgr_do_format(struct fstab_rec *fstab, bool crypt_footer) { int rc = -EINVAL; LERROR << __FUNCTION__ << ": Format " << fstab->blk_device << " as '" << fstab->fs_type << "'"; if (!strncmp(fstab->fs_type, "f2fs", 4)) { rc = format_f2fs(fstab->blk_device); } else if (!strncmp(fstab->fs_type, "ext4", 4)) { rc = format_ext4(fstab->blk_device, fstab->mount_point, crypt_footer); } else { LERROR << "File system type '" << fstab->fs_type << "' is not supported"; } return rc; }
int format(const char *vol) { const char *fsType, *dev; volume_t *volume; int result; /* Lookup the specified volume. */ volume = volume_list_lookup_by_mount_point(&volumes, vol); if (volume != NULL) { /* Check mounted volumes. */ result = volume_list_check_mounted(&volumes); if (result == 0) { /* Is the volume mounted? */ if (volume_get_mounted(volume)) { result = EBUSY; } else { /* Get file-system type. */ fsType = volume_get_fs_type(volume); /* Check if supported. */ if ((strcmp(fsType, "ext2")) && (strcmp(fsType, "ext3")) && (strcmp(fsType, "ext4"))) { result = ENOSYS; } } } } else result = ENOENT; /* Volume may be formatted? */ if (result == 0) { dev = volume_get_spec(volume); if (strcmp(fsType, "ext2") == 0) result = format_ext2(dev); if (strcmp(fsType, "ext3") == 0) result = format_ext3(dev); if (strcmp(fsType, "ext4") == 0) result = format_ext4(dev); } return result; }