source:
scripts/patches/glibc-2.3.3-lfs-5.1-m68k_fix_fcntl.patch@
78d98fc
Last change on this file since 78d98fc was 7f65c0e, checked in by , 19 years ago | |
---|---|
|
|
File size: 6.8 KB |
-
sysdeps/unix/sysv/linux/m68k/fcntl.c
diff -uNr glibc-2.3.3-lfs-5.1-ORIG/sysdeps/unix/sysv/linux/m68k/fcntl.c glibc-2.3.3-lfs-5.1/sysdeps/unix/sysv/linux/m68k/fcntl.c
old new 1 #include <sysdeps/unix/sysv/linux/i386/fcntl.c> 1 /* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc. 2 This file is part of the GNU C Library. 3 4 The GNU C Library is free software; you can redistribute it and/or 5 modify it under the terms of the GNU Lesser General Public 6 License as published by the Free Software Foundation; either 7 version 2.1 of the License, or (at your option) any later version. 8 9 The GNU C Library is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 Lesser General Public License for more details. 13 14 You should have received a copy of the GNU Lesser General Public 15 License along with the GNU C Library; if not, write to the Free 16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17 02111-1307 USA. */ 18 19 #include <assert.h> 20 #include <errno.h> 21 #include <fcntl.h> 22 #include <stdarg.h> 23 24 #include <sysdep-cancel.h> 25 #include <sys/syscall.h> 26 #include "../kernel-features.h" 27 28 /* This variable is shared with all files that check for fcntl64. */ 29 int __have_no_fcntl64; 30 31 32 int 33 __fcntl_nocancel (int fd, int cmd, ...) 34 { 35 va_list ap; 36 void *arg; 37 38 va_start (ap, cmd); 39 arg = va_arg (ap, void *); 40 va_end (ap); 41 42 switch (cmd) 43 { 44 case F_GETLK64: 45 /* Convert arg from flock64 to flock and back. */ 46 { 47 struct flock fl; 48 struct flock64 *fl64 = arg; 49 int res; 50 51 fl.l_start = (off_t)fl64->l_start; 52 /* Check if we can represent the values with the smaller type. */ 53 if ((off64_t) fl.l_start != fl64->l_start) 54 { 55 __set_errno (EOVERFLOW); 56 return -1; 57 } 58 fl.l_len = (off_t) fl64->l_len; 59 /* Check if we can represent the values with the smaller type. */ 60 if ((off64_t) fl.l_len != fl64->l_len) 61 { 62 __set_errno (EOVERFLOW); 63 return -1; 64 } 65 fl.l_type = fl64->l_type; 66 fl.l_whence = fl64->l_whence; 67 fl.l_pid = fl64->l_pid; 68 69 res = INLINE_SYSCALL (fcntl, 3, fd, F_GETLK, &fl); 70 if (res != 0) 71 return res; 72 /* Everything ok, convert back. */ 73 fl64->l_type = fl.l_type; 74 fl64->l_whence = fl.l_whence; 75 fl64->l_start = fl.l_start; 76 fl64->l_len = fl.l_len; 77 fl64->l_pid = fl.l_pid; 78 79 return 0; 80 } 81 case F_SETLK64: 82 case F_SETLKW64: 83 /* Try to convert arg from flock64 to flock. */ 84 { 85 struct flock fl; 86 struct flock64 *fl64 = arg; 87 88 fl.l_start = (off_t) fl64->l_start; 89 /* Check if we can represent the values with the smaller type. */ 90 if ((off64_t) fl.l_start != fl64->l_start) 91 { 92 __set_errno (EOVERFLOW); 93 return -1; 94 } 95 fl.l_len = (off_t)fl64->l_len; 96 /* Check if we can represent the values with the smaller type. */ 97 if ((off64_t) fl.l_len != fl64->l_len) 98 { 99 __set_errno (EOVERFLOW); 100 return -1; 101 } 102 fl.l_type = fl64->l_type; 103 fl.l_whence = fl64->l_whence; 104 fl.l_pid = fl64->l_pid; 105 assert (F_SETLK - F_SETLKW == F_SETLK64 - F_SETLKW64); 106 return INLINE_SYSCALL (fcntl, 3, fd, cmd + F_SETLK - F_SETLK64, &fl); 107 } 108 default: 109 return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg); 110 } 111 return -1; 112 } 113 114 115 int 116 __libc_fcntl (int fd, int cmd, ...) 117 { 118 va_list ap; 119 void *arg; 120 121 va_start (ap, cmd); 122 arg = va_arg (ap, void *); 123 va_end (ap); 124 125 if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64)) 126 return __fcntl_nocancel (fd, cmd, arg); 127 128 int oldtype = LIBC_CANCEL_ASYNC (); 129 130 int result = __fcntl_nocancel (fd, cmd, arg); 131 132 LIBC_CANCEL_RESET (oldtype); 133 134 return result; 135 } 136 libc_hidden_def (__libc_fcntl) 137 138 weak_alias (__libc_fcntl, __fcntl) 139 libc_hidden_weak (__fcntl) 140 weak_alias (__libc_fcntl, fcntl) -
sysdeps/unix/sysv/linux/m68k/lockf64.c
diff -uNr glibc-2.3.3-lfs-5.1-ORIG/sysdeps/unix/sysv/linux/m68k/lockf64.c glibc-2.3.3-lfs-5.1/sysdeps/unix/sysv/linux/m68k/lockf64.c
old new 1 #include <sysdeps/unix/sysv/linux/i386/lockf64.c> 1 /* Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2003 2 Free Software Foundation, Inc. 3 This file is part of the GNU C Library. 4 5 The GNU C Library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Lesser General Public 7 License as published by the Free Software Foundation; either 8 version 2.1 of the License, or (at your option) any later version. 9 10 The GNU C Library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Lesser General Public License for more details. 14 15 You should have received a copy of the GNU Lesser General Public 16 License along with the GNU C Library; if not, write to the Free 17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 18 02111-1307 USA. */ 19 20 #include <sys/types.h> 21 #include <unistd.h> 22 #include <fcntl.h> 23 #include <errno.h> 24 #include <string.h> 25 #include <sysdep.h> 26 27 #include "kernel-features.h" 28 29 /* lockf is a simplified interface to fcntl's locking facilities. */ 30 31 /* This variable is shared with all files that check for fcntl64. The 32 declaration is in fcntl.c. */ 33 extern int __have_no_fcntl64; 34 35 int 36 lockf64 (int fd, int cmd, off64_t len64) 37 { 38 struct flock fl; 39 off_t len = (off_t) len64; 40 41 memset ((char *) &fl, '\0', sizeof (fl)); 42 43 /* lockf is always relative to the current file position. */ 44 fl.l_whence = SEEK_CUR; 45 fl.l_start = 0; 46 fl.l_len = len; 47 48 if (len64 != (off64_t) len) 49 { 50 /* We can't represent the length. */ 51 __set_errno (EOVERFLOW); 52 return -1; 53 } 54 switch (cmd) 55 { 56 case F_TEST: 57 /* Test the lock: return 0 if FD is unlocked or locked by this process; 58 return -1, set errno to EACCES, if another process holds the lock. */ 59 fl.l_type = F_RDLCK; 60 if (__fcntl (fd, F_GETLK, &fl) < 0) 61 return -1; 62 if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ()) 63 return 0; 64 __set_errno (EACCES); 65 return -1; 66 case F_ULOCK: 67 fl.l_type = F_UNLCK; 68 cmd = F_SETLK; 69 break; 70 case F_LOCK: 71 fl.l_type = F_WRLCK; 72 cmd = F_SETLKW; 73 break; 74 case F_TLOCK: 75 fl.l_type = F_WRLCK; 76 cmd = F_SETLK; 77 break; 78 79 default: 80 __set_errno (EINVAL); 81 return -1; 82 } 83 return __fcntl (fd, cmd, &fl); 84 }
Note:
See TracBrowser
for help on using the repository browser.