All of lore.kernel.org
 help / color / mirror / Atom feed
From: Libor Vanek <libor@conet.cz>
To: linux-kernel@vger.kernel.org
Subject: Reading from file in module fails
Date: Mon, 3 May 2004 12:50:41 +0200	[thread overview]
Message-ID: <20040503105041.GA12023@Loki> (raw)

Hi,
I'm writing module which needs to read from file. I've got this simple sample code:

char buffer[4096];
ssize_t read;
file *f;
f = filp_open("/some/file",O_RDONLY | O_LARGEFILE,0);
f->f_pos = 0;
read = vfs_read(f,(char __user *) buffer,4096,&f->f_pos);

but here read value is "-14" (-EINVAL?) Does anybody has idea what's wrong? 

It seems that file is opened OK (I've tested:
if (f->f_op->read) {
	read = f->f_op->read(file, buf, count, pos);
}
and result was the same - so I assume that file is opened OK and structure "file f" is filled correctly.


I need to copy files (yes - I know that kernel shouldn't do this but I REALLY need) and there is nothing like "sys_copy" and "sys_sendfile" is not exported (which seems strange to me but there is nothing like EXPORT_SYMBOL(sys_sendfile) in fs/read_write.c


Thanks,
Libor Vanek


             reply	other threads:[~2004-05-03 10:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-03 10:50 Libor Vanek [this message]
2004-05-03 11:35 ` Reading from file in module fails Erik Mouw
2004-05-03 11:43   ` Libor Vanek
2004-05-03 11:48     ` Erik Mouw
2004-05-03 12:07       ` root
2004-05-03 12:41     ` Jan-Benedict Glaw
     [not found] <1RJl8-Eo-5@gated-at.bofh.it>
     [not found] ` <1RJXT-19T-37@gated-at.bofh.it>
     [not found]   ` <1RK7v-1gJ-9@gated-at.bofh.it>
     [not found]     ` <1RL3A-23k-23@gated-at.bofh.it>
2004-05-03 16:55       ` Pascal Schmidt

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=20040503105041.GA12023@Loki \
    --to=libor@conet.cz \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.