source: scripts/patches/glibc-2.3.3-lfs-5.1-m68k_fix_fcntl.patch@ 929aaed

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 929aaed was 7f65c0e, checked in by Jim Gifford <clfs@…>, 19 years ago

r625@server (orig r623): jim | 2005-10-31 12:43:24 -0800
Final Move

  • Property mode set to 100644
File size: 6.8 KB
RevLine 
[617118d]1diff -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
2--- glibc-2.3.3-lfs-5.1-ORIG/sysdeps/unix/sysv/linux/m68k/fcntl.c 2000-10-15 04:48:52.000000000 +1100
3+++ glibc-2.3.3-lfs-5.1/sysdeps/unix/sysv/linux/m68k/fcntl.c 2004-05-22 16:45:59.000000000 +1000
4@@ -1 +1,140 @@
5-#include <sysdeps/unix/sysv/linux/i386/fcntl.c>
6+/* Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
7+ This file is part of the GNU C Library.
8+
9+ The GNU C Library is free software; you can redistribute it and/or
10+ modify it under the terms of the GNU Lesser General Public
11+ License as published by the Free Software Foundation; either
12+ version 2.1 of the License, or (at your option) any later version.
13+
14+ The GNU C Library is distributed in the hope that it will be useful,
15+ but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+ Lesser General Public License for more details.
18+
19+ You should have received a copy of the GNU Lesser General Public
20+ License along with the GNU C Library; if not, write to the Free
21+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22+ 02111-1307 USA. */
23+
24+#include <assert.h>
25+#include <errno.h>
26+#include <fcntl.h>
27+#include <stdarg.h>
28+
29+#include <sysdep-cancel.h>
30+#include <sys/syscall.h>
31+#include "../kernel-features.h"
32+
33+/* This variable is shared with all files that check for fcntl64. */
34+int __have_no_fcntl64;
35+
36+
37+int
38+__fcntl_nocancel (int fd, int cmd, ...)
39+{
40+ va_list ap;
41+ void *arg;
42+
43+ va_start (ap, cmd);
44+ arg = va_arg (ap, void *);
45+ va_end (ap);
46+
47+ switch (cmd)
48+ {
49+ case F_GETLK64:
50+ /* Convert arg from flock64 to flock and back. */
51+ {
52+ struct flock fl;
53+ struct flock64 *fl64 = arg;
54+ int res;
55+
56+ fl.l_start = (off_t)fl64->l_start;
57+ /* Check if we can represent the values with the smaller type. */
58+ if ((off64_t) fl.l_start != fl64->l_start)
59+ {
60+ __set_errno (EOVERFLOW);
61+ return -1;
62+ }
63+ fl.l_len = (off_t) fl64->l_len;
64+ /* Check if we can represent the values with the smaller type. */
65+ if ((off64_t) fl.l_len != fl64->l_len)
66+ {
67+ __set_errno (EOVERFLOW);
68+ return -1;
69+ }
70+ fl.l_type = fl64->l_type;
71+ fl.l_whence = fl64->l_whence;
72+ fl.l_pid = fl64->l_pid;
73+
74+ res = INLINE_SYSCALL (fcntl, 3, fd, F_GETLK, &fl);
75+ if (res != 0)
76+ return res;
77+ /* Everything ok, convert back. */
78+ fl64->l_type = fl.l_type;
79+ fl64->l_whence = fl.l_whence;
80+ fl64->l_start = fl.l_start;
81+ fl64->l_len = fl.l_len;
82+ fl64->l_pid = fl.l_pid;
83+
84+ return 0;
85+ }
86+ case F_SETLK64:
87+ case F_SETLKW64:
88+ /* Try to convert arg from flock64 to flock. */
89+ {
90+ struct flock fl;
91+ struct flock64 *fl64 = arg;
92+
93+ fl.l_start = (off_t) fl64->l_start;
94+ /* Check if we can represent the values with the smaller type. */
95+ if ((off64_t) fl.l_start != fl64->l_start)
96+ {
97+ __set_errno (EOVERFLOW);
98+ return -1;
99+ }
100+ fl.l_len = (off_t)fl64->l_len;
101+ /* Check if we can represent the values with the smaller type. */
102+ if ((off64_t) fl.l_len != fl64->l_len)
103+ {
104+ __set_errno (EOVERFLOW);
105+ return -1;
106+ }
107+ fl.l_type = fl64->l_type;
108+ fl.l_whence = fl64->l_whence;
109+ fl.l_pid = fl64->l_pid;
110+ assert (F_SETLK - F_SETLKW == F_SETLK64 - F_SETLKW64);
111+ return INLINE_SYSCALL (fcntl, 3, fd, cmd + F_SETLK - F_SETLK64, &fl);
112+ }
113+ default:
114+ return INLINE_SYSCALL (fcntl, 3, fd, cmd, arg);
115+ }
116+ return -1;
117+}
118+
119+
120+int
121+__libc_fcntl (int fd, int cmd, ...)
122+{
123+ va_list ap;
124+ void *arg;
125+
126+ va_start (ap, cmd);
127+ arg = va_arg (ap, void *);
128+ va_end (ap);
129+
130+ if (SINGLE_THREAD_P || (cmd != F_SETLKW && cmd != F_SETLKW64))
131+ return __fcntl_nocancel (fd, cmd, arg);
132+
133+ int oldtype = LIBC_CANCEL_ASYNC ();
134+
135+ int result = __fcntl_nocancel (fd, cmd, arg);
136+
137+ LIBC_CANCEL_RESET (oldtype);
138+
139+ return result;
140+}
141+libc_hidden_def (__libc_fcntl)
142+
143+weak_alias (__libc_fcntl, __fcntl)
144+libc_hidden_weak (__fcntl)
145+weak_alias (__libc_fcntl, fcntl)
146diff -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
147--- glibc-2.3.3-lfs-5.1-ORIG/sysdeps/unix/sysv/linux/m68k/lockf64.c 2000-10-15 04:49:26.000000000 +1100
148+++ glibc-2.3.3-lfs-5.1/sysdeps/unix/sysv/linux/m68k/lockf64.c 2004-05-22 16:11:37.000000000 +1000
149@@ -1 +1,84 @@
150-#include <sysdeps/unix/sysv/linux/i386/lockf64.c>
151+/* Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000, 2003
152+ Free Software Foundation, Inc.
153+ This file is part of the GNU C Library.
154+
155+ The GNU C Library is free software; you can redistribute it and/or
156+ modify it under the terms of the GNU Lesser General Public
157+ License as published by the Free Software Foundation; either
158+ version 2.1 of the License, or (at your option) any later version.
159+
160+ The GNU C Library is distributed in the hope that it will be useful,
161+ but WITHOUT ANY WARRANTY; without even the implied warranty of
162+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
163+ Lesser General Public License for more details.
164+
165+ You should have received a copy of the GNU Lesser General Public
166+ License along with the GNU C Library; if not, write to the Free
167+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
168+ 02111-1307 USA. */
169+
170+#include <sys/types.h>
171+#include <unistd.h>
172+#include <fcntl.h>
173+#include <errno.h>
174+#include <string.h>
175+#include <sysdep.h>
176+
177+#include "kernel-features.h"
178+
179+/* lockf is a simplified interface to fcntl's locking facilities. */
180+
181+/* This variable is shared with all files that check for fcntl64. The
182+ declaration is in fcntl.c. */
183+extern int __have_no_fcntl64;
184+
185+int
186+lockf64 (int fd, int cmd, off64_t len64)
187+{
188+ struct flock fl;
189+ off_t len = (off_t) len64;
190+
191+ memset ((char *) &fl, '\0', sizeof (fl));
192+
193+ /* lockf is always relative to the current file position. */
194+ fl.l_whence = SEEK_CUR;
195+ fl.l_start = 0;
196+ fl.l_len = len;
197+
198+ if (len64 != (off64_t) len)
199+ {
200+ /* We can't represent the length. */
201+ __set_errno (EOVERFLOW);
202+ return -1;
203+ }
204+ switch (cmd)
205+ {
206+ case F_TEST:
207+ /* Test the lock: return 0 if FD is unlocked or locked by this process;
208+ return -1, set errno to EACCES, if another process holds the lock. */
209+ fl.l_type = F_RDLCK;
210+ if (__fcntl (fd, F_GETLK, &fl) < 0)
211+ return -1;
212+ if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ())
213+ return 0;
214+ __set_errno (EACCES);
215+ return -1;
216+ case F_ULOCK:
217+ fl.l_type = F_UNLCK;
218+ cmd = F_SETLK;
219+ break;
220+ case F_LOCK:
221+ fl.l_type = F_WRLCK;
222+ cmd = F_SETLKW;
223+ break;
224+ case F_TLOCK:
225+ fl.l_type = F_WRLCK;
226+ cmd = F_SETLK;
227+ break;
228+
229+ default:
230+ __set_errno (EINVAL);
231+ return -1;
232+ }
233+ return __fcntl (fd, cmd, &fl);
234+}
Note: See TracBrowser for help on using the repository browser.