Patch 3/5

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch 3/5

Lino Sanfilippo


This one disables seeking on the dazukofs devices, so one has not longer to
seek around after reading/writing on a dazukofs device.




Geschäftsführender Gesellschafter: Tjark Auerbach
Sitz der Gesellschaft: Tettnang
Handelsregister: Amtsgericht Ulm, HRB 630992
ALLGEMEINE GESCHÄFTSBEDINGUNGEN
Es gelten unsere Allgemeinen Geschäftsbedingungen
(AGB). Sie finden sie in der jeweils gültigen Fassung
im Internet unter http://www.avira.de/agb
***************************************************

diff -Nurp dazukofs-3.1.3-patch2/ctrl_dev.c dazukofs-3.1.3-patch3/ctrl_dev.c
--- dazukofs-3.1.3-patch2/ctrl_dev.c 2010-07-06 17:16:25.000000000 +0200
+++ dazukofs-3.1.3-patch3/ctrl_dev.c 2010-07-08 15:21:17.000000000 +0200
@@ -29,6 +29,11 @@
 
 static int dazukofs_ctrl_open(struct inode *inode, struct file *file)
 {
+ int rv;
+
+ rv = nonseekable_open(inode, file);
+ if (rv)
+ return rv;
  file->private_data = NULL;
  return 0;
 }
@@ -62,16 +67,12 @@ static ssize_t dazukofs_ctrl_read(struct
  }
  buflen = strlen(buf);
 
- if (*pos >= buflen)
- return 0;
-
- if (length > buflen - *pos)
- length = buflen - *pos;
+ if (length > buflen)
+ length = buflen;
 
- if (copy_to_user(buffer, buf + *pos, length))
+ if (copy_to_user(buffer, buf, length))
  return -EFAULT;
 
- *pos += length;
 
  return length;
 }
@@ -152,7 +153,6 @@ static ssize_t dazukofs_ctrl_write(struc
  }
 
  if (ret >= 0) {
- *pos += length;
  ret = length;
  }
 
@@ -167,6 +167,7 @@ static const struct file_operations ctrl
  .release = dazukofs_ctrl_release,
  .read = dazukofs_ctrl_read,
  .write = dazukofs_ctrl_write,
+ .llseek = no_llseek,
 };
 
 int dazukofs_ctrl_dev_init(int dev_major, int dev_minor,
diff -Nurp dazukofs-3.1.3-patch2/group_dev.c dazukofs-3.1.3-patch3/group_dev.c
--- dazukofs-3.1.3-patch2/group_dev.c 2010-07-06 17:20:55.000000000 +0200
+++ dazukofs-3.1.3-patch3/group_dev.c 2010-07-06 17:40:52.000000000 +0200
@@ -30,6 +30,13 @@
 static int dazukofs_group_open(int group_id, struct inode *inode,
        struct file *file)
 {
+ int rv;
+
+ rv = nonseekable_open(inode, file);
+
+ if (rv) {
+ return rv;
+ }
  if (dazukofs_group_open_tracking(group_id))
  file->private_data = file;
  else
@@ -57,8 +64,6 @@ static ssize_t dazukofs_group_read(int g
  int err;
  unsigned long event_id;
 
- if (*pos > 0)
- return 0;
 
  if (length < DAZUKOFS_MIN_READ_BUFFER)
  return -EINVAL;
@@ -79,8 +84,6 @@ static ssize_t dazukofs_group_read(int g
  if (copy_to_user(buffer, tmp, tmp_used))
  return -EFAULT;
 
- *pos = tmp_used;
-
  return tmp_used;
 }
 
@@ -120,10 +123,8 @@ static ssize_t dazukofs_group_write(int
  response = (*(p + 2)) - '0';
 
  ret = dazukofs_return_event(group_id, event_id, response);
- if (ret == 0) {
- *pos += length;
+ if (ret == 0)
  ret = length;
- }
 
  return ret;
 }
@@ -158,6 +159,7 @@ static const struct file_operations grou
  .release = dazukofs_group_release_##group_id, \
  .read = dazukofs_group_read_##group_id, \
  .write = dazukofs_group_write_##group_id, \
+ .llseek = no_llseek, \
 };
 
 DECLARE_GROUP_FOPS(0)
diff -Nurp dazukofs-3.1.3-patch2/ign_dev.c dazukofs-3.1.3-patch3/ign_dev.c
--- dazukofs-3.1.3-patch2/ign_dev.c 2010-07-06 17:16:25.000000000 +0200
+++ dazukofs-3.1.3-patch3/ign_dev.c 2010-07-08 15:24:18.000000000 +0200
@@ -108,6 +108,10 @@ static void dazukofs_remove_ign(struct f
 
 static int dazukofs_ign_open(struct inode *inode, struct file *file)
 {
+ int rv;
+ rv = nonseekable_open(inode, file);
+ if (rv)
+ return rv;
  return dazukofs_add_ign(file);
 }
 
@@ -136,6 +140,7 @@ static const struct file_operations ign_
  .owner = THIS_MODULE,
  .open = dazukofs_ign_open,
  .release = dazukofs_ign_release,
+ .llseek = no_llseek,
 };
 
 int dazukofs_ign_dev_init(int dev_major, int dev_minor,
diff -Nurp dazukofs-3.1.3-patch2/test/lib/dazukofs.c dazukofs-3.1.3-patch3/test/lib/dazukofs.c
--- dazukofs-3.1.3-patch2/test/lib/dazukofs.c 2010-07-06 17:16:25.000000000 +0200
+++ dazukofs-3.1.3-patch3/test/lib/dazukofs.c 2010-07-06 17:41:44.000000000 +0200
@@ -82,8 +82,6 @@ dazukofs_handle_t dazukofs_open(const ch
 
  if (write(fd, buf, strlen(buf)) == -1)
  goto error_out_close;
-
- lseek(fd, 0, SEEK_SET);
  }
 
  memset(buf, 0, sizeof(buf));
@@ -216,7 +214,6 @@ int dazukofs_return_access(dazukofs_hand
 
  if (write(hndl->dev_fd, buf, strlen(buf)) == -1)
  goto out;
- lseek(hndl->dev_fd, 0, SEEK_SET);
  err = 0;
 out:
  return err;

_______________________________________________
Dazuko-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/dazuko-devel
Reply | Threaded
Open this post in threaded view
|

Re: Patch 3/5

John Ogness-10
On 2010-07-08, Lino Sanfilippo <[hidden email]> wrote:
> This one disables seeking on the dazukofs devices, so one has not
> longer to seek around after reading/writing on a dazukofs device.

If seeking is disabled, the application must provide a huge buffer
when reading in the registered group names. I prefer to continue to
support partial reads. I don't think the required seek is a problem.

John Ogness

--
Dazuko Maintainer


_______________________________________________
Dazuko-devel mailing list
[hidden email]
http://lists.nongnu.org/mailman/listinfo/dazuko-devel