Fixed listing and object creation
[pohmelfs.git] / fs / pohmelfs / file.c
blob7fefdf1f6b837c7f40ecc594b33481bfcd11e8b9
1 /*
2 * Copyright (C) 2011+ Evgeniy Polyakov <zbr@ioremap.net>
3 */
5 #include <linux/fs.h>
7 #include "pohmelfs.h"
9 static int pohmelfs_send_prepare_commit(struct pohmelfs_inode *pi, size_t len, loff_t pos, int prepare)
11 struct pohmelfs_io io;
13 memset(&io, 0, sizeof(struct pohmelfs_io));
15 io.pi = pi;
16 io.id = &pi->id;
17 io.group = 2;
18 io.cmd = DNET_CMD_WRITE;
19 io.offset = pos;
20 io.num = len + pos;
21 io.aflags = DNET_ATTR_NOCSUM;
22 if (prepare)
23 io.ioflags = DNET_IO_FLAGS_PREPARE;
24 else
25 io.ioflags = DNET_IO_FLAGS_COMMIT;
26 io.ioflags |= DNET_IO_FLAGS_PLAIN_WRITE;
28 return pohmelfs_send_io(&io);
31 static ssize_t pohmelfs_write(struct file *filp, const char __user *buf, size_t len, loff_t *ppos)
33 ssize_t err;
34 #if 0
35 struct inode *inode = filp->f_mapping->host;
36 struct pohmelfs_inode *pi = pohmelfs_inode(inode);
37 loff_t offset = *ppos;
38 err = pohmelfs_send_prepare_commit(pi, len, offset, 1);
39 if (err)
40 goto err_out_exit;
41 #endif
42 err = do_sync_write(filp, buf, len, ppos);
43 #if 0
44 pohmelfs_send_prepare_commit(pi, 0, 0, 0);
45 #endif
46 err_out_exit:
47 return err;
50 const struct file_operations pohmelfs_file_ops = {
51 .open = generic_file_open,
53 .llseek = generic_file_llseek,
55 .read = do_sync_read,
56 .aio_read = generic_file_aio_read,
58 .mmap = generic_file_mmap,
60 .splice_read = generic_file_splice_read,
61 .splice_write = generic_file_splice_write,
63 .write = pohmelfs_write,
64 .aio_write = generic_file_aio_write,
67 const struct inode_operations pohmelfs_file_inode_operations = {