* make rmdir working again

* add testcase for load read/write


git-svn-id: svn+ssh://en.codiert.org/home/staff/ben/dev/misc.svn/projects/fpgafs@360 766a2236-cff9-0310-b0c0-a81a5f92509a
This commit is contained in:
ben 2007-07-10 14:18:07 +00:00
parent 9f0289c27e
commit 5477409477
6 changed files with 99 additions and 27 deletions

19
files.c
View File

@ -29,7 +29,8 @@ static int fpgafs_open(struct inode *inode, struct file *file)
//struct fpgafs_inode_info *i = FPGAFS_I(inode); //struct fpgafs_inode_info *i = FPGAFS_I(inode);
//file->private_data = i->i_ctx; //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, 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, .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 = { static const struct file_operations fpgafs_load_fops = {
.open = fpgafs_open, .open = fpgafs_open,
.write = fpgafs_load_write, .write = fpgafs_write_load,
.read = fpgafs_load_read, .read = fpgafs_read_load,
}; };
static const struct file_operations fpgafs_din_fops = { static const struct file_operations fpgafs_din_fops = {

View File

@ -50,10 +50,14 @@ struct fpgafs_lldrv {
int fpgafs_register_lldrv(struct fpgafs_lldrv *drv); int fpgafs_register_lldrv(struct fpgafs_lldrv *drv);
int fpgafs_unregister_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_send_data(struct file *file, const char __user *buf,
ssize_t fpgafs_recv_data(struct file *file, char __user *buf, size_t len, loff_t *pos); 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); ssize_t fpgafs_write_load(struct file *file, const char __user *buf,
int fpgafs_write_load(char *buf, int len); 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 */ #endif /* FPGAFS_H */

View File

@ -107,7 +107,6 @@ static int fpgafs_fill_dir(struct dentry *dir, struct tree_descr *files,
goto out; goto out;
files++; files++;
} }
return 0; return 0;
out: out:
fpgafs_prune_dir(dir); 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) static void fpgafs_prune_dir(struct dentry *dir)
{ {
struct dentry *dentry, *tmp; 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) { list_for_each_entry_safe(dentry, tmp, &dir->d_subdirs, d_u.d_child) {
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
@ -213,10 +211,9 @@ static void fpgafs_prune_dir(struct dentry *dir)
} }
} }
shrink_dcache_parent(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) static int fpgafs_rmdir(struct inode *dir, struct dentry *dentry)
{ {
/* remove all entries */ /* remove all entries */

View File

@ -27,13 +27,15 @@ ssize_t fpgafs_recv_data(struct file *file, char __user *buf,
} }
EXPORT_SYMBOL_GPL(fpgafs_recv_data); 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; return (lldrv_cur) ? lldrv_cur->write_load(buf, len) : -EBUSY;
} }
EXPORT_SYMBOL_GPL(fpgafs_write_load); 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; return (lldrv_cur) ? lldrv_cur->read_load(buf, len) : -EBUSY;
} }

5
test/go.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
insmod fpgafs.ko
insmod fpgafs_lldrv_dbg.ko
mount -t fpgafs non bla/

75
test/load_rw.c Normal file
View File

@ -0,0 +1,75 @@
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
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 <fpgafs-mountpoint>\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;
}