2 * linux/fs/umsdos/file.c
4 * Written 1992 by Jacques Gelinas
5 * inspired from linux/fs/msdos/file.c Werner Almesberger
7 * Extended MS-DOS regular file handling primitives
10 #include <linux/sched.h>
12 #include <linux/msdos_fs.h>
13 #include <linux/errno.h>
14 #include <linux/fcntl.h>
15 #include <linux/stat.h>
16 #include <linux/umsdos_fs.h>
17 #include <linux/malloc.h>
19 #include <asm/uaccess.h>
20 #include <asm/system.h>
22 static struct file_operations umsdos_symlink_operations
;
26 * Read the data associate with the symlink.
27 * Return length read in buffer or a negative error code.
31 int umsdos_readlink_x ( struct dentry
*dentry
,
35 size_t size
= dentry
->d_inode
->i_size
;
40 Printk((KERN_DEBUG
"UMSDOS_read: %s/%s, size=%u\n",
41 dentry
->d_parent
->d_name
.name
, dentry
->d_name
.name
, size
));
43 fill_new_filp (&filp
, dentry
);
45 filp
.f_flags
= O_RDONLY
;
46 filp
.f_op
= &umsdos_symlink_operations
;
51 ret
= fat_file_read (&filp
, buffer
, size
, &loffs
);
60 static int UMSDOS_readlink (struct dentry
*dentry
, char *buffer
, int buflen
)
62 return umsdos_readlink_x (dentry
, buffer
, buflen
);
65 /* this one mostly stolen from romfs :) */
66 static struct dentry
*UMSDOS_followlink (struct dentry
*dentry
,
70 struct inode
*inode
= dentry
->d_inode
;
73 mm_segment_t old_fs
= get_fs ();
75 Printk((KERN_DEBUG
"UMSDOS_followlink /mn/: (%s/%s)\n",
76 dentry
->d_parent
->d_name
.name
, dentry
->d_name
.name
));
80 if (!(symname
= kmalloc (len
+ 1, GFP_KERNEL
))) {
81 dentry
= ERR_PTR (-ENOMEM
);
85 set_fs (KERNEL_DS
); /* we read into kernel space this time */
86 cnt
= umsdos_readlink_x (dentry
, symname
, len
);
90 dentry
= ERR_PTR (-EIO
);
95 dentry
= lookup_dentry (symname
, base
, follow
);
107 /* needed to patch the file structure */
108 static struct file_operations umsdos_symlink_operations
=
110 NULL
, /* lseek - default */
113 NULL
, /* readdir - bad */
114 NULL
, /* poll - default */
115 NULL
, /* ioctl - default */
117 NULL
, /* no special open is needed */
118 NULL
, /* no flush code */
124 struct inode_operations umsdos_symlink_inode_operations
=
126 NULL
, /* default file operations (none) */
136 UMSDOS_readlink
, /* readlink */
137 UMSDOS_followlink
, /* followlink */
138 fat_get_block
, /* get_block */
139 block_read_full_page
, /* readpage */
140 NULL
, /* writepage */
141 NULL
, /* flushpage */
143 NULL
, /* permission */
145 NULL
/* revalidate */