Thanks Aboo. I was confirming my approach to set the file position in a device_open function. Regards Dinesh --- Aboo Valappil <aboo@xxxxxxxxxxxxxxx> wrote: > My thoughts ... > > cat >> /dev/CharDev0 should open the device in > append mode flag, and > your code will set the file pointer to the size. It > is up to you to > honour the file position field ( f_pos) in your > device read and device > write functions. > > Also I think you should increment the file positions > your own after read > and write. Since it is a device file I do not think > kernel is going to > execute any file system's file or inode operations. > I guess you will > have implement all these operations on your own. > > Aboo > > -----Original Message----- > From: kernelnewbies-bounce@xxxxxxxxxxxx > [mailto:kernelnewbies-bounce@xxxxxxxxxxxx] On Behalf > Of Dinesh Ahuja > Sent: Sunday, October 10, 2004 11:17 PM > To: kernelnewbies@xxxxxxxxxxxx > Subject: Appending functionality in Character Device > Driver > > I want to provide a appending functionality in a > character device driver and I have done the > following > thing in a device_open function. > > if (pfile->f_flags & O_APPEND) > { > // Opening a device file in Append Mode. > printk("<1> Append Flag has been Used\n"); > pfile->f_pos = pdevice_data->size; > } > else if ((pfile->f_flags & O_ACCMODE) == O_WRONLY) > { > // Opening a device file in Write Mode > if (pdevice_data->data) > { > kfree(pdevice_data->data); > pdevice_data->data = NULL; > pdevice_data->size = 0; > } > } > > In this , pdevice_data is a pointer to Device_Data > structure which is defined as follows: > > typedef struct Device_Data { > > void * data; > unsigned long size; > unsigned long max_size; > }Device_Data; > > Is my approach fine and is it fine If I modify on my > own pfile->f_pos in the device_open ? > > Is there any way by which Kernel takes cares of this > on its own and set the file position at the end of > the > file when I use the following commmand > > cat >> /dev/CharDev0 > > Regards > Dinesh > > > > ________________________________________________________________________ > Yahoo! India Matrimony: Find your life partner > online > Go to: http://yahoo.shaadi.com/india-matrimony > > -- > Kernelnewbies: Help each other learn about the Linux > kernel. > Archive: > http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > > ________________________________________________________________________ Yahoo! India Matrimony: Find your life partner online Go to: http://yahoo.shaadi.com/india-matrimony -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/