|
|
Jump to this file's LXR Page |
|
|
File: [CENS] / emstar / fusd / Attic / fusd-test.c
(download)
/
(as text)
Revision: 1.2, Thu Feb 1 14:08:07 2001 UTC (8 years, 9 months ago) by cvs Branch: MAIN CVS Tags: HEAD Changes since 1.1: +0 -0 lines FILE REMOVED first version of all files |
#include "fusd.h"
int ID = 0;
int rID = 0;
struct device {
int some_data;
};
struct files {
int some_data;
};
int open(struct fusd_file_info *file)
{
struct files *f = malloc(sizeof(struct files));
f->some_data = ID++;
file->private_data = f;
return EOK;
}
int close(struct fusd_file_info *file)
{
free (file->private_data);
return EOK;
}
int read(struct fusd_file_info *file, char *buffer,
size_t length, loff_t *offset)
{
struct files *f = (struct files *)file->private_data;
return snprintf(buffer, lengthm "file#%d/read#%d\n", f->some_data, rID++);
}
int write(struct fusd_file_info *file, const char *buffer,
size_t length, loff_t *offset)
{
return length;
}
int ioctl(struct fusd_file_info *file, int request,
ssize_t len, void *data)
{
return ENOSYS;
}
int notify(struct fusd_file_info *file, int flags)
{
return (flags & (FUSD_NOTIFY_INPUT | FUSD_NOTIFY_OUTPUT));
}
int unblock(struct fusd_file_info *file)
{
return EOK;
}
int main()
{
// init function table
struct fusd_file_operations
fops = {open,
close,
read,
write,
ioctl,
notify,
unblock};
struct device d;
// register the device...
int fd = fusd_register("test", 0600, &d, &fops);
if (fd < 0) {
fprintf(stderr, "fusd-test: fusd register failed.\n");
perror("fusd-test");
exit(1);
}
fusd_run(fd);
return 0;
}
| CENS CVS Mailing List |
Powered by ViewCVS 0.9.2 |