/* symlink.c */
errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
- const char *name, char *target);
+ const char *name, const char *target);
/* mmp.c */
errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf);
#include "ext2fs.h"
errcode_t ext2fs_symlink(ext2_filsys fs, ext2_ino_t parent, ext2_ino_t ino,
- const char *name, char *target)
+ const char *name, const char *target)
{
errcode_t retval;
struct ext2_inode inode;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
/* The Linux kernel doesn't allow for links longer than a block */
- target_len = strlen(target);
+ target_len = strnlen(target, fs->blocksize + 1);
if (target_len > fs->blocksize) {
retval = EXT2_ET_INVALID_ARGUMENT;
goto cleanup;
/*
* Allocate a data block for slow links
*/
+ retval = ext2fs_get_mem(fs->blocksize+1, &block_buf);
+ if (retval)
+ goto cleanup;
+ memset(block_buf, 0, fs->blocksize+1);
+ strncpy(block_buf, target, fs->blocksize);
+
memset(&inode, 0, sizeof(struct ext2_inode));
fastlink = (target_len < sizeof(inode.i_block));
if (!fastlink) {
NULL, &blk);
if (retval)
goto cleanup;
- retval = ext2fs_get_mem(fs->blocksize, &block_buf);
- if (retval)
- goto cleanup;
}
/*
retval = ext2fs_write_new_inode(fs, ino, &inode);
if (retval)
goto cleanup;
- retval = ext2fs_inline_data_set(fs, ino, &inode, target,
+ retval = ext2fs_inline_data_set(fs, ino, &inode, block_buf,
target_len);
if (retval) {
inode.i_flags &= ~EXT4_INLINE_DATA_FL;
goto cleanup;
} else {
need_block:
- ext2fs_iblk_set(fs, &inode, 1);
/* Slow symlinks, target stored in the first block */
- memset(block_buf, 0, fs->blocksize);
- strncpy(block_buf, target, fs->blocksize);
+ ext2fs_iblk_set(fs, &inode, 1);
if (fs->super->s_feature_incompat &
EXT3_FEATURE_INCOMPAT_EXTENTS) {
/*
}
#endif /* !defined HAVE_PWRITE64 && !defined HAVE_PWRITE */
-int getseed(void)
+static int getseed(void)
{
int r;
int fd;
blk64_t corrupt_blocks;
};
-int find_block_helper(ext2_filsys fs, blk64_t *blocknr, e2_blkcnt_t blockcnt,
- blk64_t ref_blk, int ref_offset, void *priv_data)
+static int find_block_helper(ext2_filsys fs EXT2FS_ATTR((unused)),
+ blk64_t *blocknr, e2_blkcnt_t blockcnt,
+ blk64_t ref_blk EXT2FS_ATTR((unused)),
+ int ref_offset EXT2FS_ATTR((unused)),
+ void *priv_data)
{
struct find_block *fb = (struct find_block *)priv_data;
return 0;
}
-errcode_t find_metadata_blocks(ext2_filsys fs, ext2fs_block_bitmap bmap,
- off_t *corrupt_bytes)
+static errcode_t find_metadata_blocks(ext2_filsys fs, ext2fs_block_bitmap bmap,
+ off_t *corrupt_bytes)
{
dgrp_t i;
blk64_t b, c;
return retval;
}
-uint64_t rand_num(uint64_t min, uint64_t max)
+static uint64_t rand_num(uint64_t min, uint64_t max)
{
uint64_t x;
- int i;
+ unsigned int i;
uint8_t *px = (uint8_t *)&x;
for (i = 0; i < sizeof(x); i++)
return min + (uint64_t)((double)(max - min) * (x / (UINT64_MAX + 1.0)));
}
-int process_fs(const char *fsname)
+static int process_fs(const char *fsname)
{
errcode_t ret;
int flags, fd;
ext2fs_block_bitmap corrupt_map;
off_t hsize, count, off, offset, corrupt_bytes;
unsigned char c;
- unsigned long i;
+ off_t i;
/* If mounted rw, force dryrun mode */
ret = ext2fs_check_if_mounted(fsname, &flags);
return 1;
}
-void print_help(const char *progname)
+static void print_help(const char *progname)
{
printf("Usage: %s OPTIONS device\n", progname);
printf("-b: Corrupt this many bytes.\n");
#endif
#ifndef HAVE_ADD_KEY
-key_serial_t add_key(const char *type, const char *description,
- const void *payload, size_t plen,
- key_serial_t keyring)
+static key_serial_t add_key(const char *type, const char *description,
+ const void *payload, size_t plen,
+ key_serial_t keyring)
{
return syscall(__NR_add_key, type, description, payload,
plen, keyring);
}
#endif
-static const char *hexchars = "0123456789abcdef";
+static const unsigned char *hexchars = (const unsigned char *) "0123456789abcdef";
static const size_t hexchars_size = 16;
#define SHA512_LENGTH 64
exit(1);
}
-static int hex2byte(const char *hex, size_t hex_size, char *bytes,
+static int hex2byte(const char *hex, size_t hex_size, unsigned char *bytes,
size_t bytes_size)
{
- int x;
- char *h, *l;
+ size_t x;
+ unsigned char *h, *l;
if (hex_size % 2)
return -EINVAL;
struct salt *salt_list;
unsigned num_salt;
unsigned max_salt;
-char passphrase[EXT4_MAX_PASSPHRASE_SIZE];
+char in_passphrase[EXT4_MAX_PASSPHRASE_SIZE];
static struct salt *find_by_salt(unsigned char *salt, size_t salt_len)
{
- int i;
+ unsigned int i;
struct salt *p;
for (i = 0, p = salt_list; i < num_salt; i++, p++)
free(salt_list);
salt_list = NULL;
}
- memset(passphrase, 0, sizeof(passphrase));
+ memset(in_passphrase, 0, sizeof(in_passphrase));
}
static void die_signal_handler(int signum EXT2FS_ATTR((unused)),
exit(-1);
}
-void sigcatcher_setup(void)
+static void sigcatcher_setup(void)
{
struct sigaction sa;
static void parse_salt(char *salt_str, int flags)
{
unsigned char buf[EXT4_MAX_SALT_SIZE];
- unsigned char *salt_buf, *cp = salt_str;
+ char *cp = salt_str;
+ unsigned char *salt_buf;
int fd, ret, salt_len = 0;
if (flags & PARSE_FLAGS_FORCE_FN)
salt_len = strlen(cp);
if (salt_len >= EXT4_MAX_SALT_SIZE)
goto invalid_salt;
- strncpy(buf, cp, sizeof(buf));
+ strncpy((char *) buf, cp, sizeof(buf));
} else if (cp[0] == '/') {
salt_from_filename:
fd = open(cp, O_RDONLY | O_DIRECTORY);
cp += 2;
goto salt_from_filename;
} else if (strncmp(cp, "0x", 2) == 0) {
- char *h, *l;
+ unsigned char *h, *l;
cp += 2;
if (strlen(cp) & 1)
}
}
-static void pbkdf2_sha512(const char *passphrase, struct salt *salt, int count,
- char derived_key[EXT4_MAX_KEY_SIZE])
+static void pbkdf2_sha512(const char *passphrase, struct salt *salt,
+ unsigned int count,
+ unsigned char derived_key[EXT4_MAX_KEY_SIZE])
{
size_t passphrase_size = strlen(passphrase);
- char buf[SHA512_LENGTH + EXT4_MAX_PASSPHRASE_SIZE] = {0};
- char tempbuf[SHA512_LENGTH] = {0};
+ unsigned char buf[SHA512_LENGTH + EXT4_MAX_PASSPHRASE_SIZE] = {0};
+ unsigned char tempbuf[SHA512_LENGTH] = {0};
char final[SHA512_LENGTH] = {0};
- char saltbuf[EXT4_MAX_SALT_SIZE + EXT4_MAX_PASSPHRASE_SIZE] = {0};
+ unsigned char saltbuf[EXT4_MAX_SALT_SIZE + EXT4_MAX_PASSPHRASE_SIZE] = {0};
int actual_buf_len = SHA512_LENGTH + passphrase_size;
int actual_saltbuf_len = EXT4_MAX_SALT_SIZE + passphrase_size;
- int x, y;
+ unsigned int x, y;
__u32 *final_u32 = (__u32 *)final;
__u32 *temp_u32 = (__u32 *)tempbuf;
if (passphrase_size > EXT4_MAX_PASSPHRASE_SIZE) {
- printf("Passphrase size is %d; max is %d.\n", passphrase_size,
+ printf("Passphrase size is %zd; max is %d.\n", passphrase_size,
EXT4_MAX_PASSPHRASE_SIZE);
exit(1);
}
if (salt->salt_len > EXT4_MAX_SALT_SIZE) {
- printf("Salt size is %d; max is %d.\n", salt->salt_len,
+ printf("Salt size is %zd; max is %d.\n", salt->salt_len,
EXT4_MAX_SALT_SIZE);
exit(1);
}
return rc;
}
-void get_passphrase(char *passphrase, int len)
+static void get_passphrase(char *passphrase, int len)
{
char *p;
struct termios current_settings;
static int get_keyring_id(const char *keyring)
{
- int x;
+ unsigned int x;
char *end;
/*
return keyrings[x].code;
}
}
- x = strtol(keyring, &end, 10);
+ x = strtoul(keyring, &end, 10);
if (*end == '\0') {
if (keyctl(KEYCTL_DESCRIBE, x, NULL, 0) < 0)
return 0;
static void generate_key_ref_str(struct salt *salt)
{
- char key_ref1[SHA512_LENGTH];
- char key_ref2[SHA512_LENGTH];
+ unsigned char key_ref1[SHA512_LENGTH];
+ unsigned char key_ref2[SHA512_LENGTH];
int x;
ext2fs_sha512(salt->key, EXT4_MAX_KEY_SIZE, key_ref1);
}
}
-void get_default_salts(void)
+static void get_default_salts(void)
{
FILE *f = setmntent("/etc/mtab", "r");
struct mntent *mnt;
#define CMD_HIDDEN 0x0001
-void do_help(int argc, char **argv, const struct cmd_desc *cmd);
+static void do_help(int argc, char **argv, const struct cmd_desc *cmd);
#define add_key_desc "adds a key to the user's keyring"
#define add_key_help \
"set the policy of those directories to use the key just entered by\n" \
"the user.\n"
-void do_add_key(int argc, char **argv, const struct cmd_desc *cmd)
+static void do_add_key(int argc, char **argv, const struct cmd_desc *cmd)
{
struct salt *salt;
char *keyring = NULL;
int i, opt, pad = 4;
+ unsigned j;
while ((opt = getopt(argc, argv, "k:S:p:vq")) != -1) {
switch (opt) {
for (i = optind; i < argc; i++)
parse_salt(argv[i], PARSE_FLAGS_FORCE_FN);
printf("Enter passphrase (echo disabled): ");
- get_passphrase(passphrase, sizeof(passphrase));
- for (i = 0, salt = salt_list; i < num_salt; i++, salt++) {
- pbkdf2_sha512(passphrase, salt,
+ get_passphrase(in_passphrase, sizeof(in_passphrase));
+ for (j = 0, salt = salt_list; j < num_salt; j++, salt++) {
+ pbkdf2_sha512(in_passphrase, salt,
EXT4_PBKDF2_ITERATIONS, salt->key);
generate_key_ref_str(salt);
insert_key_into_keyring(keyring, salt);
"policy matches what was specified. A policy is an encryption key\n" \
"identifier consisting of 16 hexadecimal characters.\n"
-void do_set_policy(int argc, char **argv, const struct cmd_desc *cmd)
+static void do_set_policy(int argc, char **argv, const struct cmd_desc *cmd)
{
struct salt saltbuf;
int c, pad = 4;
"e4crypt get_policy path ... \n\n" \
"Gets the policy for the directories specified on the command line.\n"
-void do_get_policy(int argc, char **argv, const struct cmd_desc *cmd)
+static void do_get_policy(int argc, char **argv, const struct cmd_desc *cmd)
{
struct ext4_encryption_policy policy;
struct stat st;
"Give the invoking process (typically a shell) a new session keyring,\n" \
"discarding its old session keyring.\n"
-void do_new_session(int argc, char **argv EXT2FS_ATTR((unused)),
- const struct cmd_desc *cmd)
+static void do_new_session(int argc, char **argv EXT2FS_ATTR((unused)),
+ const struct cmd_desc *cmd)
{
long keyid, ret;
{ NULL, NULL, NULL, NULL, 0 }
};
-void do_help(int argc, char **argv,
- const struct cmd_desc *cmd EXT2FS_ATTR((unused)))
+static void do_help(int argc, char **argv,
+ const struct cmd_desc *cmd EXT2FS_ATTR((unused)))
{
const struct cmd_desc *p;
if (argc < 2)
do_help(argc, argv, cmd_list);
+ sigcatcher_setup();
for (cmd = cmd_list; cmd->cmd_name; cmd++) {
if (strcmp(cmd->cmd_name, argv[1]) == 0) {
cmd->cmd_func(argc-1, argv+1, cmd);
exit(EXIT_FAILURE);
}
#else
+#ifndef _LARGEFILE_SOURCE
+#define _LARGEFILE_SOURCE
+#endif
+#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
+#endif
+
#include <stdio.h>
#include <stdlib.h>
print_flag(&fe_flags, mask, flags, hex);
}
- if (fm_extent->fe_logical + fm_extent->fe_length >= st->st_size)
+ if (fm_extent->fe_logical + fm_extent->fe_length >=
+ (unsigned long long) st->st_size)
strcat(flags, "eof,");
/* Remove trailing comma, if any */
*/
#define _FILE_OFFSET_BITS 64
#define FUSE_USE_VERSION 29
+#ifndef _GNU_SOURCE
#define _GNU_SOURCE
+#endif
#include "config.h"
#include <pthread.h>
#ifdef __linux__
size_t h_sz;
ext4_acl_entry *e;
acl_ea_entry *a;
- void *hptr;
+ unsigned char *hptr;
errcode_t err;
facl_count = acl_ea_count(facl_sz);
return err;
h->a_version = ext2fs_cpu_to_le32(EXT4_ACL_VERSION);
- hptr = h + 1;
+ hptr = (unsigned char *) (h + 1);
for (i = 0, a = facl->a_entries; i < facl_count; i++, a++) {
- e = hptr;
+ e = (ext4_acl_entry *) hptr;
e->e_tag = ext2fs_cpu_to_le16(a->e_tag);
e->e_perm = ext2fs_cpu_to_le16(a->e_perm);
ext4_acl_entry *e;
acl_ea_entry *a;
size_t f_sz;
- void *hptr;
+ unsigned char *hptr;
errcode_t err;
eacl_count = ext4_acl_count(eacl_sz);
return err;
f->a_version = ACL_EA_VERSION;
- hptr = eacl + 1;
+ hptr = (unsigned char *) (eacl + 1);
for (i = 0, a = f->a_entries; i < eacl_count; i++, a++) {
- e = hptr;
+ e = (ext4_acl_entry *) hptr;
a->e_tag = ext2fs_le16_to_cpu(e->e_tag);
a->e_perm = ext2fs_le16_to_cpu(e->e_perm);
#define EXT4_FITS_IN_INODE(ext4_inode, field) \
((offsetof(typeof(*ext4_inode), field) + \
sizeof((ext4_inode)->field)) \
- <= (EXT2_GOOD_OLD_INODE_SIZE + \
+ <= ((size_t) EXT2_GOOD_OLD_INODE_SIZE + \
(ext4_inode)->i_extra_isize)) \
static inline __u32 ext4_encode_extra_time(const struct timespec *time)
return (fs->flags & EXT2_FLAG_RW) && (fs->super->s_error_count == 0);
}
-static int check_inum_access(ext2_filsys fs, ext2_ino_t ino, int mask)
+static int check_inum_access(ext2_filsys fs, ext2_ino_t ino, mode_t mask)
{
struct fuse_context *ctxt = fuse_get_context();
struct ext2_inode inode;
return -EACCES;
}
-static void op_destroy(void *p)
+static void op_destroy(void *p EXT2FS_ATTR((unused)))
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
/* Create symlink */
- err = ext2fs_symlink(fs, parent, 0, node_name, (char *)src);
+ err = ext2fs_symlink(fs, parent, 0, node_name, src);
if (err == EXT2_ET_DIR_NO_SPACE) {
err = ext2fs_expand_dir(fs, parent);
if (err) {
goto out2;
}
- err = ext2fs_symlink(fs, parent, 0, node_name, (char *)src);
+ err = ext2fs_symlink(fs, parent, 0, node_name, src);
}
if (err) {
ret = translate_error(fs, parent, err);
ext2_ino_t new_dotdot;
};
-static int update_dotdot_helper(ext2_ino_t dir, int entry,
- struct ext2_dir_entry *dirent, int offset,
- int blocksize, char *buf, void *priv_data)
+static int update_dotdot_helper(ext2_ino_t dir EXT2FS_ATTR((unused)),
+ int entry EXT2FS_ATTR((unused)),
+ struct ext2_dir_entry *dirent,
+ int offset EXT2FS_ATTR((unused)),
+ int blocksize EXT2FS_ATTR((unused)),
+ char *buf EXT2FS_ATTR((unused)),
+ void *priv_data)
{
struct update_dotdot *ud = priv_data;
}
/* FUSE seems to feed us ~0 to mean "don't change" */
- if (owner != ~0) {
+ if (owner != (uid_t) ~0) {
/* Only root gets to change UID. */
if (ctxt->uid != 0 &&
!(inode.i_uid == ctxt->uid && owner == ctxt->uid)) {
inode.i_uid = owner;
}
- if (group != ~0) {
+ if (group != (gid_t) ~0) {
/* Only root or the owner get to change GID. */
if (ctxt->uid != 0 && inode.i_uid != ctxt->uid) {
ret = -EPERM;
return ret;
}
-static int op_read(const char *path, char *buf, size_t len, off_t offset,
- struct fuse_file_info *fp)
+static int op_read(const char *path EXT2FS_ATTR((unused)), char *buf,
+ size_t len, off_t offset,
+ struct fuse_file_info *fp)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
}
out:
pthread_mutex_unlock(&ff->bfl);
- return got ? got : ret;
+ return got ? (int) got : ret;
}
-static int op_write(const char *path, const char *buf, size_t len, off_t offset,
- struct fuse_file_info *fp)
+static int op_write(const char *path EXT2FS_ATTR((unused)),
+ const char *buf, size_t len, off_t offset,
+ struct fuse_file_info *fp)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
out:
pthread_mutex_unlock(&ff->bfl);
- return got ? got : ret;
+ return got ? (int) got : ret;
}
-static int op_release(const char *path, struct fuse_file_info *fp)
+static int op_release(const char *path EXT2FS_ATTR((unused)),
+ struct fuse_file_info *fp)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
return ret;
}
-static int op_fsync(const char *path, int datasync, struct fuse_file_info *fp)
+static int op_fsync(const char *path EXT2FS_ATTR((unused)),
+ int datasync EXT2FS_ATTR((unused)),
+ struct fuse_file_info *fp)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
return ret;
}
-static int op_statfs(const char *path, struct statvfs *buf)
+static int op_statfs(const char *path EXT2FS_ATTR((unused)),
+ struct statvfs *buf)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
typedef errcode_t (*xattr_xlate_get)(void **cooked_buf, size_t *cooked_sz,
const void *raw_buf, size_t raw_sz);
typedef errcode_t (*xattr_xlate_set)(const void *cooked_buf, size_t cooked_sz,
- void **raw_buf, size_t *raw_sz);
+ const void **raw_buf, size_t *raw_sz);
struct xattr_translate {
const char *prefix;
xattr_xlate_get get;
return ret;
}
-static int count_buffer_space(char *name, char *value, size_t value_len,
+static int count_buffer_space(char *name, char *value EXT2FS_ATTR((unused)),
+ size_t value_len EXT2FS_ATTR((unused)),
void *data)
{
unsigned int *x = data;
return 0;
}
-static int copy_names(char *name, char *value, size_t value_len, void *data)
+static int copy_names(char *name, char *value EXT2FS_ATTR((unused)),
+ size_t value_len EXT2FS_ATTR((unused)), void *data)
{
char **b = data;
return ret;
}
-static int op_setxattr(const char *path, const char *key, const char *value,
- size_t len, int flags)
+static int op_setxattr(const char *path EXT2FS_ATTR((unused)),
+ const char *key, const char *value,
+ size_t len, int flags EXT2FS_ATTR((unused)))
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
ext2_filsys fs;
struct ext2_xattr_handle *h;
struct xattr_translate *xt;
- void *cvalue;
+ const void *cvalue;
size_t clen;
ext2_ino_t ino;
errcode_t err;
goto out2;
}
- cvalue = (void *)value;
+ cvalue = value;
clen = len;
for (xt = xattr_translators; xt->prefix != NULL; xt++) {
if (strncmp(key, xt->prefix, strlen(xt->prefix)) == 0) {
fuse_fill_dir_t func;
};
-static int op_readdir_iter(ext2_ino_t dir, int entry,
- struct ext2_dir_entry *dirent, int offset,
- int blocksize, char *buf, void *data)
+static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)),
+ int entry EXT2FS_ATTR((unused)),
+ struct ext2_dir_entry *dirent,
+ int offset EXT2FS_ATTR((unused)),
+ int blocksize EXT2FS_ATTR((unused)),
+ char *buf EXT2FS_ATTR((unused)), void *data)
{
struct readdir_iter *i = data;
char namebuf[EXT2_NAME_LEN + 1];
return 0;
}
-static int op_readdir(const char *path, void *buf, fuse_fill_dir_t fill_func,
- off_t offset, struct fuse_file_info *fp)
+static int op_readdir(const char *path EXT2FS_ATTR((unused)),
+ void *buf, fuse_fill_dir_t fill_func,
+ off_t offset EXT2FS_ATTR((unused)),
+ struct fuse_file_info *fp)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
return ret;
}
-static int op_ftruncate(const char *path, off_t len, struct fuse_file_info *fp)
+static int op_ftruncate(const char *path EXT2FS_ATTR((unused)),
+ off_t len, struct fuse_file_info *fp)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
return 0;
}
-static int op_fgetattr(const char *path, struct stat *statbuf,
+static int op_fgetattr(const char *path EXT2FS_ATTR((unused)),
+ struct stat *statbuf,
struct fuse_file_info *fp)
{
struct fuse_context *ctxt = fuse_get_context();
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
- struct timespec *tv = (struct timespec *)ctv;
+ struct timespec tv[2];
ext2_filsys fs;
errcode_t err;
ext2_ino_t ino;
goto out;
}
+ tv[0] = ctv[0];
+ tv[1] = ctv[1];
#ifdef UTIME_NOW
if (tv[0].tv_nsec == UTIME_NOW)
get_now(tv);
#endif /* FITRIM */
#if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
-static int op_ioctl(const char *path, int cmd, void *arg,
- struct fuse_file_info *fp, unsigned int flags, void *data)
+static int op_ioctl(const char *path EXT2FS_ATTR((unused)), int cmd,
+ void *arg EXT2FS_ATTR((unused)),
+ struct fuse_file_info *fp,
+ unsigned int flags EXT2FS_ATTR((unused)), void *data)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
FUSE2FS_CHECK_CONTEXT(ff);
fs = ff->fs;
pthread_mutex_lock(&ff->bfl);
- switch (cmd) {
+ switch ((unsigned long) cmd) {
#ifdef SUPPORT_I_FLAGS
case EXT2_IOC_GETFLAGS:
ret = ioctl_getflags(fs, fh, data);
}
#endif /* FUSE 28 */
-static int op_bmap(const char *path, size_t blocksize, uint64_t *idx)
+static int op_bmap(const char *path, size_t blocksize EXT2FS_ATTR((unused)),
+ uint64_t *idx)
{
struct fuse_context *ctxt = fuse_get_context();
struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data;
/* Update i_size */
if (!(mode & FL_KEEP_SIZE_FLAG)) {
- if (offset + len > fsize) {
+ if ((__u64) offset + len > fsize) {
err = ext2fs_inode_size_set(fs,
(struct ext2_inode *)&inode,
offset + len);
return 0;
}
-static int op_fallocate(const char *path, int mode, off_t offset, off_t len,
+static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode,
+ off_t offset, off_t len,
struct fuse_file_info *fp)
{
struct fuse_context *ctxt = fuse_get_context();
int fd;
ssize_t r;
- fd = open("/dev/random", O_RDONLY);
+ fd = open("/dev/urandom", O_RDONLY);
if (fd < 0) {
- perror("/dev/random");
+ perror("/dev/urandom");
return 0;
}
r = read(fd, p, sz);
close(fd);
- return r == sz;
+ return (size_t) r == sz;
}
static void print_help(const char *progname)
if (linux_version_code == 0)
return 0;
- return linux_version_code < KERNEL_VERSION(major, minor, rev);
+ return linux_version_code < (int) KERNEL_VERSION(major, minor, rev);
}
#else
static int is_before_linux_ver(unsigned int major, unsigned int minor,
* device's alignment offset, if any, or a negative error.
*/
static int get_device_geometry(const char *file,
- struct ext2_super_block *fs_param,
- int psector_size)
+ struct ext2_super_block *param,
+ unsigned int psector_size)
{
int rc = -1;
- int blocksize;
+ unsigned int blocksize;
blkid_probe pr;
blkid_topology tp;
unsigned long min_io;
min_io = blkid_topology_get_minimum_io_size(tp);
opt_io = blkid_topology_get_optimal_io_size(tp);
- blocksize = EXT2_BLOCK_SIZE(fs_param);
+ blocksize = EXT2_BLOCK_SIZE(param);
if ((min_io == 0) && (psector_size > blocksize))
min_io = psector_size;
if ((opt_io == 0) && min_io)
/* setting stripe/stride to blocksize is pointless */
if (min_io > blocksize)
- fs_param->s_raid_stride = min_io / blocksize;
+ param->s_raid_stride = min_io / blocksize;
if (opt_io > blocksize)
- fs_param->s_raid_stripe_width = opt_io / blocksize;
+ param->s_raid_stripe_width = opt_io / blocksize;
rc = blkid_topology_get_alignment_offset(tp);
out:
}
#ifdef HAVE_BLKID_PROBE_GET_TOPOLOGY
- retval = get_device_geometry(device_name, &fs_param, psector_size);
+ retval = get_device_geometry(device_name, &fs_param,
+ (unsigned int) psector_size);
if (retval < 0) {
fprintf(stderr,
_("warning: Unable to get device geometry for %s\n"),
return retval;
}
-int
+static int
fs_update_journal_user(struct ext2_super_block *sb, __u8 old_uuid[UUID_SIZE])
{
int retval, nr_users, start;
struct ext2_super_block *sb;
io_manager io_ptr, io_ptr_orig = NULL;
int rc = 0;
+ char default_undo_file[1] = { 0 };
#ifdef ENABLE_NLS
setlocale(LC_MESSAGES, "");
* If inode resize is requested use the
* Undo I/O manager
*/
- undo_file = "";
+ undo_file = default_undo_file;
}
/* Set up an undo file */