From 158648c0bdda281e252a27c0200dd0ea6f4e0215 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 1 Apr 2011 10:33:37 -0400 Subject: [PATCH] Add support for name_to_handle_at and open_by_handle. --- ChangeLog | 13 +++++++ NEWS | 4 +-- sysdeps/unix/sysv/linux/Versions | 2 ++ sysdeps/unix/sysv/linux/i386/bits/fcntl.h | 48 ++++++++++++++++++++++--- sysdeps/unix/sysv/linux/ia64/bits/fcntl.h | 53 +++++++++++++++++++++++---- sysdeps/unix/sysv/linux/s390/bits/fcntl.h | 53 +++++++++++++++++++++++---- sysdeps/unix/sysv/linux/sh/bits/fcntl.h | 55 ++++++++++++++++++++++++---- sysdeps/unix/sysv/linux/sparc/bits/fcntl.h | 48 ++++++++++++++++++++++--- sysdeps/unix/sysv/linux/syscalls.list | 3 ++ sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h | 56 +++++++++++++++++++++++++---- 10 files changed, 297 insertions(+), 38 deletions(-) diff --git a/ChangeLog b/ChangeLog index b9c96d2c2a..c63d3ef50a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2011-04-01 Ulrich Drepper + * sysdeps/unix/sysv/linux/Versions [GLIBC_2.14] (name_to_handle_at, + open_by_handle): Add. + * sysdeps/unix/sysv/linux/i386/bits/fcntl.h: Define struct file_handle + and MAX_HANDLE_SZ. Declare name_to_handle_at and open_by_handle. + Augment a few comments. + * sysdeps/unix/sysv/linux/ia64/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/s390/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/sh/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/sparc/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h: Likewise. + * sysdeps/unix/sysv/linux/syscalls.list: Add name_to_handle_at and + open_by_handle. + * io/fcntl.h (AT_EMPTY_PATH): Define. 2011-03-30 Ulrich Drepper diff --git a/NEWS b/NEWS index eba3e8b435..54257ac894 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -GNU C Library NEWS -- history of user-visible changes. 2011-3-30 +GNU C Library NEWS -- history of user-visible changes. 2011-4-1 Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc. See the end for copying conditions. @@ -7,7 +7,7 @@ using `glibc' in the "product" field. Version 2.14 -* New Linux interfaces: clock_adjtime +* New Linux interfaces: clock_adjtime, name_to_handle_at, open_by_handle * The following bugs are resolved with this release: diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 24ea75e1ac..52d0cde118 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -156,6 +156,8 @@ libc { } GLIBC_2.14 { clock_adjtime; + + name_to_handle_at; open_by_handle; } GLIBC_PRIVATE { # functions used in other libraries diff --git a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h index 944a3209be..51a18c2af2 100644 --- a/sysdeps/unix/sysv/linux/i386/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/i386/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007, 2009, 2010 + Copyright (C) 1995-1998, 2000, 2004, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -232,6 +232,19 @@ struct f_owner_ex we splice from/to). */ # define SPLICE_F_MORE 4 /* Expect more data. */ # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */ + + +/* File handle structure. */ +struct file_handle +{ + unsigned int handle_bytes; + int handle_type; + /* File identifier. */ + unsigned char f_handle[0]; +}; + +/* Maximum handle size (for now). */ +# define MAX_HANDLE_SZ 128 #endif __BEGIN_DECLS @@ -248,20 +261,32 @@ extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags); -/* Splice address range into a pipe. */ +/* Splice address range into a pipe. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags); -/* Splice two files together. */ +/* Splice two files together. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, __off64_t *__offout, size_t __len, unsigned int __flags); -/* In-kernel implementation of tee for pipe buffers. */ +/* In-kernel implementation of tee for pipe buffers. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t tee (int __fdin, int __fdout, size_t __len, unsigned int __flags); -/* Reserve storage for the data of the file associated with FD. */ +/* Reserve storage for the data of the file associated with FD. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else @@ -278,6 +303,19 @@ extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len); # endif + +/* Map file name to file handle. */ +extern int name_to_handle_at (int __dfd, const char *__name, + struct file_handle *__handle, int *__mnt_id, + int __flags) __THROW; + +/* Open file using the file handle. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int open_by_handle (int __mountdirfd, struct file_handle *__handle, + int __flags); + #endif __END_DECLS diff --git a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h index 2189a97228..0421d14bd3 100644 --- a/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/ia64/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/IA64. - Copyright (C) 1999, 2000, 2004, 2006, 2007, 2009, 2010 + Copyright (C) 1999, 2000, 2004, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -227,6 +227,19 @@ struct f_owner_ex we splice from/to). */ # define SPLICE_F_MORE 4 /* Expect more data. */ # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */ + + +/* File handle structure. */ +struct file_handle +{ + unsigned int handle_bytes; + int handle_type; + /* File identifier. */ + unsigned char f_handle[0]; +}; + +/* Maximum handle size (for now). */ +# define MAX_HANDLE_SZ 128 #endif __BEGIN_DECLS @@ -238,25 +251,40 @@ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; -/* Selective file content synch'ing. */ +/* Selective file content synch'ing. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags); -/* Splice address range into a pipe. */ +/* Splice address range into a pipe. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags); -/* Splice two files together. */ +/* Splice two files together. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, __off64_t *__offout, size_t __len, unsigned int __flags); -/* In-kernel implementation of tee for pipe buffers. */ +/* In-kernel implementation of tee for pipe buffers. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t tee (int __fdin, int __fdout, size_t __len, unsigned int __flags); -/* Reserve storage for the data of the file associated with FD. */ +/* Reserve storage for the data of the file associated with FD. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else @@ -273,6 +301,19 @@ extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len); # endif + +/* Map file name to file handle. */ +extern int name_to_handle_at (int __dfd, const char *__name, + struct file_handle *__handle, int *__mnt_id, + int __flags) __THROW; + +/* Open file using the file handle. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int open_by_handle (int __mountdirfd, struct file_handle *__handle, + int __flags); + #endif __END_DECLS diff --git a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h index 05c7a3ba82..4226b9c9ac 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/s390/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 2000-2002,2004,2006,2007,2009,2010 + Copyright (C) 2000-2002,2004,2006,2007,2009,2010,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -253,6 +253,19 @@ struct f_owner_ex we splice from/to). */ # define SPLICE_F_MORE 4 /* Expect more data. */ # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */ + + +/* File handle structure. */ +struct file_handle +{ + unsigned int handle_bytes; + int handle_type; + /* File identifier. */ + unsigned char f_handle[0]; +}; + +/* Maximum handle size (for now). */ +# define MAX_HANDLE_SZ 128 #endif __BEGIN_DECLS @@ -264,25 +277,40 @@ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; -/* Selective file content synch'ing. */ +/* Selective file content synch'ing. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags); -/* Splice address range into a pipe. */ +/* Splice address range into a pipe. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags); -/* Splice two files together. */ +/* Splice two files together. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, __off64_t *__offout, size_t __len, unsigned int __flags); -/* In-kernel implementation of tee for pipe buffers. */ +/* In-kernel implementation of tee for pipe buffers. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t tee (int __fdin, int __fdout, size_t __len, unsigned int __flags); -/* Reserve storage for the data of the file associated with FD. */ +/* Reserve storage for the data of the file associated with FD. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else @@ -299,6 +327,19 @@ extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len); # endif + +/* Map file name to file handle. */ +extern int name_to_handle_at (int __dfd, const char *__name, + struct file_handle *__handle, int *__mnt_id, + int __flags) __THROW; + +/* Open file using the file handle. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int open_by_handle (int __mountdirfd, struct file_handle *__handle, + int __flags); + #endif __END_DECLS diff --git a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h index df21f6af42..35f30f9e7b 100644 --- a/sysdeps/unix/sysv/linux/sh/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sh/bits/fcntl.h @@ -1,5 +1,5 @@ -/* O_*, F_*, FD_* bit values for Linux. - Copyright (C) 1995, 1996, 1997, 1998, 2000, 2004, 2006, 2007, 2009, 2010 +/* O_*, F_*, FD_* bit values for Linux/SH. + Copyright (C) 1995-1998, 2000, 2004, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -233,6 +233,19 @@ struct f_owner_ex we splice from/to). */ # define SPLICE_F_MORE 4 /* Expect more data. */ # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */ + + +/* File handle structure. */ +struct file_handle +{ + unsigned int handle_bytes; + int handle_type; + /* File identifier. */ + unsigned char f_handle[0]; +}; + +/* Maximum handle size (for now). */ +# define MAX_HANDLE_SZ 128 #endif __BEGIN_DECLS @@ -244,25 +257,40 @@ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; -/* Selective file content synch'ing. */ +/* Selective file content synch'ing. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags); -/* Splice address range into a pipe. */ +/* Splice address range into a pipe. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags); -/* Splice two files together. */ +/* Splice two files together. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, __off64_t *__offout, size_t __len, unsigned int __flags); -/* In-kernel implementation of tee for pipe buffers. */ +/* In-kernel implementation of tee for pipe buffers. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t tee (int __fdin, int __fdout, size_t __len, unsigned int __flags); -/* Reserve storage for the data of the file associated with FD. */ +/* Reserve storage for the data of the file associated with FD. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else @@ -279,6 +307,19 @@ extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len); # endif + +/* Map file name to file handle. */ +extern int name_to_handle_at (int __dfd, const char *__name, + struct file_handle *__handle, int *__mnt_id, + int __flags) __THROW; + +/* Open file using the file handle. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int open_by_handle (int __mountdirfd, struct file_handle *__handle, + int __flags); + #endif __END_DECLS diff --git a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h index bf8f3d60e9..468b8cf8d9 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/SPARC. - Copyright (C) 1995-1998, 2000, 2003, 2004, 2006, 2007, 2009, 2010 + Copyright (C) 1995-1998, 2000, 2003, 2004, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -243,6 +243,19 @@ struct f_owner_ex we splice from/to). */ # define SPLICE_F_MORE 4 /* Expect more data. */ # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */ + + +/* File handle structure. */ +struct file_handle +{ + unsigned int handle_bytes; + int handle_type; + /* File identifier. */ + unsigned char f_handle[0]; +}; + +/* Maximum handle size (for now). */ +# define MAX_HANDLE_SZ 128 #endif __BEGIN_DECLS @@ -254,7 +267,10 @@ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; -/* Selective file content synch'ing. */ +/* Selective file content synch'ing. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags); @@ -263,16 +279,25 @@ extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count, extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags); -/* Splice two files together. */ +/* Splice two files together. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, __off64_t *__offout, size_t __len, unsigned int __flags); -/* In-kernel implementation of tee for pipe buffers. */ +/* In-kernel implementation of tee for pipe buffers. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t tee (int __fdin, int __fdout, size_t __len, unsigned int __flags); -/* Reserve storage for the data of the file associated with FD. */ +/* Reserve storage for the data of the file associated with FD. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else @@ -289,6 +314,19 @@ extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len); # endif + +/* Map file name to file handle. */ +extern int name_to_handle_at (int __dfd, const char *__name, + struct file_handle *__handle, int *__mnt_id, + int __flags) __THROW; + +/* Open file using the file handle. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int open_by_handle (int __mountdirfd, struct file_handle *__handle, + int __flags); + #endif __END_DECLS diff --git a/sysdeps/unix/sysv/linux/syscalls.list b/sysdeps/unix/sysv/linux/syscalls.list index 03c784b492..ed2d5f61c0 100644 --- a/sysdeps/unix/sysv/linux/syscalls.list +++ b/sysdeps/unix/sysv/linux/syscalls.list @@ -104,3 +104,6 @@ timerfd_settime EXTRA timerfd_settime i:iipp timerfd_settime timerfd_gettime EXTRA timerfd_gettime i:ip timerfd_gettime fanotify_init EXTRA fanotify_init i:ii fanotify_init + +name_to_handle_at EXTRA name_to_handle_at i:isppi name_to_handle_at +open_by_handle EXTRA open_by_handle Ci:ipi open_by_handle diff --git a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h index ac029fddae..925c813cb7 100644 --- a/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h +++ b/sysdeps/unix/sysv/linux/x86_64/bits/fcntl.h @@ -1,5 +1,5 @@ /* O_*, F_*, FD_* bit values for Linux/x86-64. - Copyright (C) 2001,2002,2004,2006,2007,2009,2010 + Copyright (C) 2001,2002,2004,2006,2007,2009,2010,2011 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -247,6 +247,19 @@ struct f_owner_ex we splice from/to). */ # define SPLICE_F_MORE 4 /* Expect more data. */ # define SPLICE_F_GIFT 8 /* Pages passed in are a gift. */ + + +/* File handle structure. */ +struct file_handle +{ + unsigned int handle_bytes; + int handle_type; + /* File identifier. */ + unsigned char f_handle[0]; +}; + +/* Maximum handle size (for now). */ +# define MAX_HANDLE_SZ 128 #endif __BEGIN_DECLS @@ -258,25 +271,40 @@ extern ssize_t readahead (int __fd, __off64_t __offset, size_t __count) __THROW; -/* Selective file content synch'ing. */ +/* Selective file content synch'ing. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern int sync_file_range (int __fd, __off64_t __offset, __off64_t __count, unsigned int __flags); -/* Splice address range into a pipe. */ +/* Splice address range into a pipe. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t vmsplice (int __fdout, const struct iovec *__iov, size_t __count, unsigned int __flags); -/* Splice two files together. */ +/* Splice two files together. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t splice (int __fdin, __off64_t *__offin, int __fdout, __off64_t *__offout, size_t __len, unsigned int __flags); -/* In-kernel implementation of tee for pipe buffers. */ +/* In-kernel implementation of tee for pipe buffers. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ extern ssize_t tee (int __fdin, int __fdout, size_t __len, unsigned int __flags); -/* Reserve storage for the data of the file associated with FD. */ +/* Reserve storage for the data of the file associated with FD. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ # ifndef __USE_FILE_OFFSET64 extern int fallocate (int __fd, int __mode, __off_t __offset, __off_t __len); # else @@ -292,6 +320,20 @@ extern int __REDIRECT (fallocate, (int __fd, int __mode, __off64_t __offset, extern int fallocate64 (int __fd, int __mode, __off64_t __offset, __off64_t __len); # endif -#endif + + +/* Map file name to file handle. */ +extern int name_to_handle_at (int __dfd, const char *__name, + struct file_handle *__handle, int *__mnt_id, + int __flags) __THROW; + +/* Open file using the file handle. + + This function is a possible cancellation point and therefore not + marked with __THROW. */ +extern int open_by_handle (int __mountdirfd, struct file_handle *__handle, + int __flags); + +#endif /* use GNU */ __END_DECLS -- 2.11.4.GIT