ftpfs.c: fix several compiler warnings, especially around printf specifiers
This commit is contained in:
69
ftpfs.c
69
ftpfs.c
@@ -274,7 +274,10 @@ static int ftpfs_readdir(const char* path, void *dbuf, fuse_fill_dir_t filler,
|
|||||||
off_t offset, struct fuse_file_info *fi,
|
off_t offset, struct fuse_file_info *fi,
|
||||||
enum fuse_readdir_flags flags) {
|
enum fuse_readdir_flags flags) {
|
||||||
// N.B.: fuse.h tells us that we can ignore `offset` and pass 0 to the filler where it would expect an offset.
|
// N.B.: fuse.h tells us that we can ignore `offset` and pass 0 to the filler where it would expect an offset.
|
||||||
|
(void) offset;
|
||||||
// fuse_cache_dirfil_t handle = (struct dir_handle*) fi->fh; //< set by us in `open`
|
// fuse_cache_dirfil_t handle = (struct dir_handle*) fi->fh; //< set by us in `open`
|
||||||
|
(void) fi;
|
||||||
|
(void) flags; //< TODO(colin): is this safe to ignore?
|
||||||
|
|
||||||
int err = 0;
|
int err = 0;
|
||||||
CURLcode curl_res;
|
CURLcode curl_res;
|
||||||
@@ -306,6 +309,8 @@ static int ftpfs_readdir(const char* path, void *dbuf, fuse_fill_dir_t filler,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int ftpfs_getattr(const char* path, struct stat* sbuf, struct fuse_file_info* fi) {
|
static int ftpfs_getattr(const char* path, struct stat* sbuf, struct fuse_file_info* fi) {
|
||||||
|
(void) fi; //< TODO(colin): is this safe to ignore?
|
||||||
|
|
||||||
int err;
|
int err;
|
||||||
CURLcode curl_res;
|
CURLcode curl_res;
|
||||||
char* dir_path = get_dir_path(path);
|
char* dir_path = get_dir_path(path);
|
||||||
@@ -354,12 +359,12 @@ static size_t ftpfs_read_chunk(const char* full_path, char* rbuf,
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
struct ftpfs_file* fh = get_ftpfs_file(fi);
|
struct ftpfs_file* fh = get_ftpfs_file(fi);
|
||||||
|
|
||||||
DEBUG(2, "ftpfs_read_chunk: %s %p %zu %lld %p %p\n",
|
DEBUG(2, "ftpfs_read_chunk: %s %p %zu %ld %p %p\n",
|
||||||
full_path, rbuf, size, offset, fi, fh);
|
full_path, rbuf, size, offset, fi, fh);
|
||||||
|
|
||||||
pthread_mutex_lock(&ftpfs.lock);
|
pthread_mutex_lock(&ftpfs.lock);
|
||||||
|
|
||||||
DEBUG(2, "buffer size: %zu %lld\n", fh->buf.len, fh->buf.begin_offset);
|
DEBUG(2, "buffer size: %zu %ld\n", fh->buf.len, fh->buf.begin_offset);
|
||||||
|
|
||||||
if ((fh->buf.len < size + offset - fh->buf.begin_offset) ||
|
if ((fh->buf.len < size + offset - fh->buf.begin_offset) ||
|
||||||
offset < fh->buf.begin_offset ||
|
offset < fh->buf.begin_offset ||
|
||||||
@@ -371,7 +376,7 @@ static size_t ftpfs_read_chunk(const char* full_path, char* rbuf,
|
|||||||
!check_running()) {
|
!check_running()) {
|
||||||
DEBUG(1, "We need to restart the connection %p\n", ftpfs.connection);
|
DEBUG(1, "We need to restart the connection %p\n", ftpfs.connection);
|
||||||
DEBUG(2, "current_fh=%p fh=%p\n", ftpfs.current_fh, fh);
|
DEBUG(2, "current_fh=%p fh=%p\n", ftpfs.current_fh, fh);
|
||||||
DEBUG(2, "buf.begin_offset=%lld offset=%lld\n", fh->buf.begin_offset, offset);
|
DEBUG(2, "buf.begin_offset=%ld offset=%ld\n", fh->buf.begin_offset, offset);
|
||||||
|
|
||||||
buf_clear(&fh->buf);
|
buf_clear(&fh->buf);
|
||||||
fh->buf.begin_offset = offset;
|
fh->buf.begin_offset = offset;
|
||||||
@@ -522,7 +527,7 @@ static void *ftpfs_write_thread(void *data) {
|
|||||||
struct ftpfs_file *fh = data;
|
struct ftpfs_file *fh = data;
|
||||||
char range[15];
|
char range[15];
|
||||||
|
|
||||||
DEBUG(2, "enter streaming write thread #%d path=%s pos=%lld\n", ++write_thread_ctr, fh->full_path, fh->pos);
|
DEBUG(2, "enter streaming write thread #%d path=%s pos=%ld\n", ++write_thread_ctr, fh->full_path, fh->pos);
|
||||||
|
|
||||||
|
|
||||||
curl_easy_setopt_or_die(fh->write_conn, CURLOPT_URL, fh->full_path);
|
curl_easy_setopt_or_die(fh->write_conn, CURLOPT_URL, fh->full_path);
|
||||||
@@ -642,23 +647,23 @@ static void free_ftpfs_file(struct ftpfs_file *fh) {
|
|||||||
free(fh);
|
free(fh);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int buffer_file(struct ftpfs_file *fh) {
|
// static int buffer_file(struct ftpfs_file *fh) {
|
||||||
// If we want to write to the file, we have to load it all at once,
|
// // If we want to write to the file, we have to load it all at once,
|
||||||
// modify it in memory and then upload it as a whole as most FTP servers
|
// // modify it in memory and then upload it as a whole as most FTP servers
|
||||||
// don't support resume for uploads.
|
// // don't support resume for uploads.
|
||||||
pthread_mutex_lock(&ftpfs.lock);
|
// pthread_mutex_lock(&ftpfs.lock);
|
||||||
cancel_previous_multi();
|
// cancel_previous_multi();
|
||||||
curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, fh->full_path);
|
// curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_URL, fh->full_path);
|
||||||
curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &fh->buf);
|
// curl_easy_setopt_or_die(ftpfs.connection, CURLOPT_WRITEDATA, &fh->buf);
|
||||||
CURLcode curl_res = curl_easy_perform(ftpfs.connection);
|
// CURLcode curl_res = curl_easy_perform(ftpfs.connection);
|
||||||
pthread_mutex_unlock(&ftpfs.lock);
|
// pthread_mutex_unlock(&ftpfs.lock);
|
||||||
|
//
|
||||||
if (curl_res != 0) {
|
// if (curl_res != 0) {
|
||||||
return -EACCES;
|
// return -EACCES;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
static int create_empty_file(const char * path)
|
static int create_empty_file(const char * path)
|
||||||
{
|
{
|
||||||
@@ -760,7 +765,7 @@ static int ftpfs_open_common(const char* path, mode_t mode,
|
|||||||
size_t size = ftpfs_read_chunk(fh->full_path, NULL, 1, 0, fi, 0);
|
size_t size = ftpfs_read_chunk(fh->full_path, NULL, 1, 0, fi, 0);
|
||||||
|
|
||||||
if (size == CURLFTPFS_BAD_READ) {
|
if (size == CURLFTPFS_BAD_READ) {
|
||||||
DEBUG(1, "initial read failed size=%d\n", size);
|
DEBUG(1, "initial read failed size=%zu\n", size);
|
||||||
err = -EACCES;
|
err = -EACCES;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -847,7 +852,7 @@ static int ftpfs_read(const char* path, char* rbuf, size_t size, off_t offset,
|
|||||||
int ret;
|
int ret;
|
||||||
struct ftpfs_file *fh = get_ftpfs_file(fi);
|
struct ftpfs_file *fh = get_ftpfs_file(fi);
|
||||||
|
|
||||||
DEBUG(1, "ftpfs_read: %s size=%zu offset=%lld has_write_conn=%d pos=%lld\n", path, size, (long long) offset, fh->write_conn!=0, fh->pos);
|
DEBUG(1, "ftpfs_read: %s size=%zu offset=%ld has_write_conn=%d pos=%ld\n", path, size, offset, fh->write_conn!=0, fh->pos);
|
||||||
|
|
||||||
if (fh->pos>0 || fh->write_conn!=NULL)
|
if (fh->pos>0 || fh->write_conn!=NULL)
|
||||||
{
|
{
|
||||||
@@ -887,6 +892,7 @@ static int ftpfs_mknod(const char* path, mode_t mode, dev_t rdev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int ftpfs_chmod(const char* path, mode_t mode, struct fuse_file_info* fi) {
|
static int ftpfs_chmod(const char* path, mode_t mode, struct fuse_file_info* fi) {
|
||||||
|
(void) fi; //< TODO(colin): is this safe to ignore?
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
// We can only process a subset of the mode - so strip
|
// We can only process a subset of the mode - so strip
|
||||||
@@ -928,7 +934,7 @@ static int ftpfs_chmod(const char* path, mode_t mode, struct fuse_file_info* fi)
|
|||||||
static int ftpfs_chown(const char* path, uid_t uid, gid_t gid, struct fuse_file_info* fi) {
|
static int ftpfs_chown(const char* path, uid_t uid, gid_t gid, struct fuse_file_info* fi) {
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
DEBUG(1, "ftpfs_chown: %d %d %u\n", (int)uid, (int)gid, fi);
|
DEBUG(1, "ftpfs_chown: %d %d %p\n", (int)uid, (int)gid, fi);
|
||||||
|
|
||||||
struct curl_slist* header = NULL;
|
struct curl_slist* header = NULL;
|
||||||
char* full_path = get_dir_path(path);
|
char* full_path = get_dir_path(path);
|
||||||
@@ -967,7 +973,7 @@ static int ftpfs_chown(const char* path, uid_t uid, gid_t gid, struct fuse_file_
|
|||||||
|
|
||||||
static int ftpfs_ftruncate(const char * path , off_t offset, struct fuse_file_info * fi)
|
static int ftpfs_ftruncate(const char * path , off_t offset, struct fuse_file_info * fi)
|
||||||
{
|
{
|
||||||
DEBUG(1, "ftpfs_ftruncate: %s len=%lld\n", path, offset);
|
DEBUG(1, "ftpfs_ftruncate: %s len=%ld\n", path, offset);
|
||||||
struct ftpfs_file *fh = get_ftpfs_file(fi);
|
struct ftpfs_file *fh = get_ftpfs_file(fi);
|
||||||
|
|
||||||
if (offset == 0)
|
if (offset == 0)
|
||||||
@@ -996,7 +1002,7 @@ static int ftpfs_truncate(const char* path, off_t offset, struct fuse_file_info*
|
|||||||
if (fi)
|
if (fi)
|
||||||
return ftpfs_ftruncate(path, offset, fi);
|
return ftpfs_ftruncate(path, offset, fi);
|
||||||
|
|
||||||
DEBUG(1, "ftpfs_truncate: %s len=%lld\n", path, offset);
|
DEBUG(1, "ftpfs_truncate: %s len=%ld\n", path, offset);
|
||||||
/* we can't use ftpfs_mknod here, because we don't know the right permissions */
|
/* we can't use ftpfs_mknod here, because we don't know the right permissions */
|
||||||
if (offset == 0) return op_return(create_empty_file(path), "ftpfs_truncate");
|
if (offset == 0) return op_return(create_empty_file(path), "ftpfs_truncate");
|
||||||
|
|
||||||
@@ -1017,6 +1023,7 @@ static int ftpfs_truncate(const char* path, off_t offset, struct fuse_file_info*
|
|||||||
static int ftpfs_utimens(const char* path, struct utimbuf* time, struct fuse_file_info* fi) {
|
static int ftpfs_utimens(const char* path, struct utimbuf* time, struct fuse_file_info* fi) {
|
||||||
(void) path;
|
(void) path;
|
||||||
(void) time;
|
(void) time;
|
||||||
|
(void) fi;
|
||||||
return op_return(0, "ftpfs_utimens");
|
return op_return(0, "ftpfs_utimens");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1134,7 +1141,7 @@ static int ftpfs_write(const char *path, const char *wbuf, size_t size,
|
|||||||
(void) path;
|
(void) path;
|
||||||
struct ftpfs_file *fh = get_ftpfs_file(fi);
|
struct ftpfs_file *fh = get_ftpfs_file(fi);
|
||||||
|
|
||||||
DEBUG(1, "ftpfs_write: %s size=%zu offset=%lld has_write_conn=%d pos=%lld\n", path, size, (long long) offset, fh->write_conn!=0, fh->pos);
|
DEBUG(1, "ftpfs_write: %s size=%zu offset=%ld has_write_conn=%d pos=%ld\n", path, size, offset, fh->write_conn!=0, fh->pos);
|
||||||
|
|
||||||
if (fh->write_fail_cause != CURLE_OK)
|
if (fh->write_fail_cause != CURLE_OK)
|
||||||
{
|
{
|
||||||
@@ -1144,7 +1151,7 @@ static int ftpfs_write(const char *path, const char *wbuf, size_t size,
|
|||||||
|
|
||||||
if (!fh->write_conn && fh->pos == 0 && offset == 0)
|
if (!fh->write_conn && fh->pos == 0 && offset == 0)
|
||||||
{
|
{
|
||||||
DEBUG(1, "ftpfs_write: starting a streaming write at pos=%lld\n", fh->pos);
|
DEBUG(1, "ftpfs_write: starting a streaming write at pos=%ld\n", fh->pos);
|
||||||
|
|
||||||
/* check if the file has been truncated to zero or has been newly created */
|
/* check if the file has been truncated to zero or has been newly created */
|
||||||
if (!fh->write_may_start)
|
if (!fh->write_may_start)
|
||||||
@@ -1169,7 +1176,7 @@ static int ftpfs_write(const char *path, const char *wbuf, size_t size,
|
|||||||
if (!fh->write_conn && fh->pos >0 && offset == fh->pos)
|
if (!fh->write_conn && fh->pos >0 && offset == fh->pos)
|
||||||
{
|
{
|
||||||
/* resume a streaming write */
|
/* resume a streaming write */
|
||||||
DEBUG(1, "ftpfs_write: resuming a streaming write at pos=%lld\n", fh->pos);
|
DEBUG(1, "ftpfs_write: resuming a streaming write at pos=%ld\n", fh->pos);
|
||||||
|
|
||||||
int success = start_write_thread(fh);
|
int success = start_write_thread(fh);
|
||||||
if (!success)
|
if (!success)
|
||||||
@@ -1221,7 +1228,7 @@ static int ftpfs_flush(const char *path, struct fuse_file_info *fi) {
|
|||||||
int err = 0;
|
int err = 0;
|
||||||
struct ftpfs_file* fh = get_ftpfs_file(fi);
|
struct ftpfs_file* fh = get_ftpfs_file(fi);
|
||||||
|
|
||||||
DEBUG(1, "ftpfs_flush: buf.len=%zu buf.pos=%lld write_conn=%d\n", fh->buf.len, fh->pos, fh->write_conn!=0);
|
DEBUG(1, "ftpfs_flush: buf.len=%zu buf.pos=%ld write_conn=%d\n", fh->buf.len, fh->pos, fh->write_conn!=0);
|
||||||
|
|
||||||
if (fh->write_conn) {
|
if (fh->write_conn) {
|
||||||
err = finish_write_thread(fh);
|
err = finish_write_thread(fh);
|
||||||
@@ -1238,7 +1245,7 @@ static int ftpfs_flush(const char *path, struct fuse_file_info *fi) {
|
|||||||
if (sbuf.st_size != fh->pos)
|
if (sbuf.st_size != fh->pos)
|
||||||
{
|
{
|
||||||
fh->write_fail_cause = -999;
|
fh->write_fail_cause = -999;
|
||||||
dprintf(ftpfs.stderr_fd, "ftpfs_flush: check filesize problem: size=%lld expected=%lld\n", sbuf.st_size, fh->pos);
|
dprintf(ftpfs.stderr_fd, "ftpfs_flush: check filesize problem: size=%ld expected=%ld\n", sbuf.st_size, fh->pos);
|
||||||
return op_return(-EIO, "ftpfs_flush");
|
return op_return(-EIO, "ftpfs_flush");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user