From: Davide Libenzi <davidel@xmailserver.org>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Ulrich Drepper <drepper@redhat.com>, Ingo Molnar <mingo@elte.hu>,
Eric Dumazet <dada1@cosmosbay.com>
Subject: [patch 4/8] fdmap v2 - add a new O_NONSEQFD flag to sys_open
Date: Wed, 06 Jun 2007 15:30:31 -0700 [thread overview]
Message-ID: <send-serie.davidel@xmailserver.org.4625.1181169038.4> (raw)
This patch introduces a new O_NONSEQFD flag for the sys_open()
system call. Using such flag, the caller can ask the kernel to allocate
the file descriptor inside the non-sequential area.
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
- Davide
Index: linux-2.6.mod/fs/open.c
===================================================================
--- linux-2.6.mod.orig/fs/open.c 2007-06-06 12:48:03.000000000 -0700
+++ linux-2.6.mod/fs/open.c 2007-06-06 12:48:37.000000000 -0700
@@ -978,6 +978,23 @@
return FDMAP_NONSEQ_BASE + (rndb & ((1U << FDMAP_RANDOM_BITS) - 1));
}
+/**
+ * allocate_fd - Allocates a new file descriptor
+ *
+ * @flags: [in] Flags to control the allocation type and the new descriptor
+ * characteristics
+ *
+ * Returns the newly allocated file descriptor, or a negative value in
+ * case of error.
+ */
+int allocate_fd(unsigned long flags)
+{
+ if (flags & O_NONSEQFD)
+ return alloc_nonseq_fd(current->files, flags);
+ else
+ return get_unused_fd();
+}
+
/*
* Install a file pointer in the fd array.
*
@@ -1011,7 +1028,7 @@
int fd = PTR_ERR(tmp);
if (!IS_ERR(tmp)) {
- fd = get_unused_fd();
+ fd = allocate_fd((unsigned int) flags);
if (fd >= 0) {
struct file *f = do_filp_open(dfd, tmp, flags, mode);
if (IS_ERR(f)) {
Index: linux-2.6.mod/include/asm-generic/fcntl.h
===================================================================
--- linux-2.6.mod.orig/include/asm-generic/fcntl.h 2007-06-06 12:38:27.000000000 -0700
+++ linux-2.6.mod/include/asm-generic/fcntl.h 2007-06-06 12:48:37.000000000 -0700
@@ -48,6 +48,9 @@
#ifndef O_NOATIME
#define O_NOATIME 01000000
#endif
+#ifndef O_NONSEQFD
+#define O_NONSEQFD 02000000
+#endif
#ifndef O_NDELAY
#define O_NDELAY O_NONBLOCK
#endif
Index: linux-2.6.mod/include/linux/file.h
===================================================================
--- linux-2.6.mod.orig/include/linux/file.h 2007-06-06 12:48:28.000000000 -0700
+++ linux-2.6.mod/include/linux/file.h 2007-06-06 12:48:37.000000000 -0700
@@ -85,6 +85,7 @@
extern int __alloc_nonseq_fd(struct files_struct *files, unsigned long flags);
extern int alloc_nonseq_fd(struct files_struct *files, unsigned long flags);
extern unsigned int gen_nonseqfd_base(void);
+extern int allocate_fd(unsigned long flags);
/**
* nonseq_files_fdmap - Must be called with @files->file_lock held. It forces
reply other threads:[~2007-06-06 22:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=send-serie.davidel@xmailserver.org.4625.1181169038.4 \
--to=davidel@xmailserver.org \
--cc=akpm@linux-foundation.org \
--cc=dada1@cosmosbay.com \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=torvalds@linux-foundation.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
all inboxes | Powered by JetHome®