5633l3

Listing 3. Creating a File to which a User Can Read and
Write

static struct dentry *fs_create_file (const char *name, mode_t mode,
                                      struct dentry *parent, void *data,
                                      struct file_operations *fops)
{
        struct dentry *dentry;
        int error;

        dbg("creating file '%s'\n",name);

        error = pcihpfs_create_by_name(name,mode,parent,&dentry);
        if (error) {
                dentry = NULL;
        } else {
                if (dentry->d_inode) {
                        if (data)
                                dentry->d_inode->u.generic_ip = data;
                        if (fops)
                        dentry->d_inode->i_fop = fops;
                }
        }

        return dentry;
}
