mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Arne Henrichsen <ahenric@gmail.com>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Problems with close() system call
Date: Tue, 26 Oct 2004 14:43:54 +0200	[thread overview]
Message-ID: <605a56ed04102605433b9f368@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.53.0410261329410.26803@yvahk01.tjqt.qr>

On Tue, 26 Oct 2004 13:30:35 +0200 (MEST), Jan Engelhardt
<jengelh@linux01.gwdg.de> wrote:
> 
> Best is to put a printk("i'm in ioctl()") in the ioctl() function and a
> printk("i'm in close()") in the close() one, to be really sure whether the
> close() function of your module is called.
> 

Yes, that is exactly what I am doing. I basically implement the
flush() call (for close) as the release() call was never called on
close. So my release call does nothing. What I see is that the flush
function gets called, even though I have never called the close()
system call from my user app.

I also print out the module counter, and it doesn't make sense who
increments it:

open(0): f_count = 1
ioctl(0): f_count = 2
ioctl(0): f_count = 5
open(1)): f_count = 1
ioctl(1): f_count = 2
flush(0): f_count = 7
ioctl(1): f_count = 5
open(2): f_count = 1
ioctl(2): f_count = 2
flush(1): f_count = 7

My user app looks something like this:
int fd[8];

for(i = 0; i < nr_dev; i)
  {
    sprintf(dev, "/dev/mydev_%c", '0' + i);
    fd[i] = open(dev, O_RDWR | O_SYNC);
    if(fd[i] < 0)
    {
      printf("Error opening device: %s - %s\n", dev, strerror(errno));
      goto test_error;
    }

    status = ioctl(fd[i], CMD1);
    if(status != 0)
    {
      printf("%s - %s\n", dev, strerror(errno));
    }

    status = ioctl(fd[i], CMD2);
    if(status != 0)
    {
      printf("%s - %s\n", dev, strerror(errno));
    }
  } /* for(port_id = 0; port_id < nr_ports; port_id++) */
  
Arne

  reply	other threads:[~2004-10-26 12:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-25 11:40 Arne Henrichsen
2004-10-26 11:30 ` Jan Engelhardt
2004-10-26 12:43   ` Arne Henrichsen [this message]
2004-10-26 15:43     ` Jan Engelhardt
2004-10-27  4:48       ` Raj

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=605a56ed04102605433b9f368@mail.gmail.com \
    --to=ahenric@gmail.com \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome