diff --git a/files.c b/files.c index d1169c0..93f0c8c 100644 --- a/files.c +++ b/files.c @@ -29,7 +29,8 @@ static int fpgafs_open(struct inode *inode, struct file *file) //struct fpgafs_inode_info *i = FPGAFS_I(inode); //file->private_data = i->i_ctx; - return 0; // nonseekable_open(inode, file); + //return nonseekable_open(inode, file); + return 0; } static ssize_t fpgafs_stat_read(struct file *file, char __user *buf, @@ -74,22 +75,10 @@ static const struct file_operations fpgafs_cmd_fops = { .write = fpgafs_cmd_write, }; -static ssize_t fpgafs_load_read(struct file *file, char __user *buf, - size_t len, loff_t *pos) -{ - return 0; -} - -static ssize_t fpgafs_load_write(struct file *file, const char __user *buf, - size_t len, loff_t *pos) -{ - return 0; -} - static const struct file_operations fpgafs_load_fops = { .open = fpgafs_open, - .write = fpgafs_load_write, - .read = fpgafs_load_read, + .write = fpgafs_write_load, + .read = fpgafs_read_load, }; static const struct file_operations fpgafs_din_fops = { diff --git a/fpgafs.h b/fpgafs.h index 1d5e4d5..d37504e 100644 --- a/fpgafs.h +++ b/fpgafs.h @@ -50,10 +50,14 @@ struct fpgafs_lldrv { int fpgafs_register_lldrv(struct fpgafs_lldrv *drv); int fpgafs_unregister_lldrv(struct fpgafs_lldrv *drv); -ssize_t fpgafs_send_data(struct file *file, const char __user *buf, size_t len, loff_t *pos); -ssize_t fpgafs_recv_data(struct file *file, char __user *buf, size_t len, loff_t *pos); +ssize_t fpgafs_send_data(struct file *file, const char __user *buf, + size_t len, loff_t *pos); +ssize_t fpgafs_recv_data(struct file *file, char __user *buf, + size_t len, loff_t *pos); -int fpgafs_read_load(char *buf, int len); -int fpgafs_write_load(char *buf, int len); +ssize_t fpgafs_write_load(struct file *file, const char __user *buf, + size_t len, loff_t *pos); +ssize_t fpgafs_read_load(struct file *file, char __user *buf, + size_t len, loff_t *pos); #endif /* FPGAFS_H */ diff --git a/inode.c b/inode.c index 14c9c0f..89ee957 100644 --- a/inode.c +++ b/inode.c @@ -105,9 +105,8 @@ static int fpgafs_fill_dir(struct dentry *dir, struct tree_descr *files, files->mode & mode, ctx); if (ret) goto out; - files++; + files++; } - return 0; out: fpgafs_prune_dir(dir); @@ -195,8 +194,7 @@ int fpgafs_mkdir( struct inode *dir, struct dentry *dentry, int mode) static void fpgafs_prune_dir(struct dentry *dir) { struct dentry *dentry, *tmp; - - mutex_lock(&dir->d_inode->i_mutex); + //mutex_lock(&dir->d_inode->i_mutex); list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) { spin_lock(&dcache_lock); spin_lock(&dentry->d_lock); @@ -213,10 +211,9 @@ static void fpgafs_prune_dir(struct dentry *dir) } } shrink_dcache_parent(dir); - mutex_unlock(&dir->d_inode->i_mutex); + //mutex_unlock(&dir->d_inode->i_mutex); } -/* Caller must hold parent->i_mutex */ static int fpgafs_rmdir(struct inode *dir, struct dentry *dentry) { /* remove all entries */ diff --git a/llmgmt.c b/llmgmt.c index 6e6c9cd..6a31802 100644 --- a/llmgmt.c +++ b/llmgmt.c @@ -27,13 +27,15 @@ ssize_t fpgafs_recv_data(struct file *file, char __user *buf, } EXPORT_SYMBOL_GPL(fpgafs_recv_data); -int fpgafs_write_load(char *buf, int len) +ssize_t fpgafs_write_load(struct file *file, const char __user *buf, + size_t len, loff_t *pos) { return (lldrv_cur) ? lldrv_cur->write_load(buf, len) : -EBUSY; } EXPORT_SYMBOL_GPL(fpgafs_write_load); -int fpgafs_read_load(char *buf, int len) +ssize_t fpgafs_read_load(struct file *file, char __user *buf, + size_t len, loff_t *pos) { return (lldrv_cur) ? lldrv_cur->read_load(buf, len) : -EBUSY; } diff --git a/test/go.sh b/test/go.sh new file mode 100755 index 0000000..3db7ae3 --- /dev/null +++ b/test/go.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +insmod fpgafs.ko +insmod fpgafs_lldrv_dbg.ko +mount -t fpgafs non bla/ diff --git a/test/load_rw.c b/test/load_rw.c new file mode 100644 index 0000000..a9bfa0a --- /dev/null +++ b/test/load_rw.c @@ -0,0 +1,75 @@ +#include +#include +#include +#include +#include +#include + +static char src[] = { 0x12, 0x34, 0x56, 0x78, 0x90}; +static char des[] = { 0x0, 0x0, 0x0, 0x0, 0x0}; + +/* + * LOAD WRITE/READ TEST + */ +int +main(int argc, char **argv) +{ + int fd, res, i; + char *str, *dir, *tmp; + + if (argc < 2) { + printf("USAGE: %.20 \n", argv[0]); + return -1; + } + + dir=malloc(sizeof(argv[1]) + 10); + str=malloc(sizeof(argv[1]) + 15); + sprintf(dir, "%s/bla", argv[1]); + sprintf(str, "%s/bla/load", argv[1]); + + if (mkdir(dir, 0777) == -1) { + printf("ERROR-1: %s\n", strerror(errno)); + return -1; + } + printf("created: %s\n", dir); + + if ((fd = open(str, O_WRONLY, 0)) == -1) { + printf("ERROR-2: %s\n", strerror(errno)); + return -1; + } + printf("opened: %s\n", str); + + if ((res=write(fd, src, sizeof(src))) == -1) { + printf("ERROR-3: %s\n", strerror(errno)); + return -1; + } + printf("written (%d): ", res); + for (i=0; i < sizeof(src); i++) + printf("0x%x ", src[i]); + printf("\n"); + close(fd); + + if ((fd = open(str, O_RDONLY, 0)) == -1) { + printf("ERROR-4: %s\n", strerror(errno)); + return -1; + } + printf("opened: %s\n", str); + + if ((res=read(fd, des, sizeof(des))) == -1) { + printf("ERROR-5: %s\n", strerror(errno)); + return -1; + } + printf("read (%d): ", res); + for (i=0; i < sizeof(des); i++) + printf("0x%x ", des[i]); + printf("\n"); + close(fd); + + if (rmdir(dir) == -1) { + printf("ERROR-6: %s\n", strerror(errno)); + return -1; + } + printf("removed: %s\n", dir); + + return 0; +}