Deleted Added
full compact
linux_util.c (179486) linux_util.c (184205)
1/*-
2 * Copyright (c) 1994 Christos Zoulas
3 * Copyright (c) 1995 Frank van der Linden
4 * Copyright (c) 1995 Scott Bartram
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1994 Christos Zoulas
3 * Copyright (c) 1995 Frank van der Linden
4 * Copyright (c) 1995 Scott Bartram
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

--- 16 unchanged lines hidden (view full) ---

25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *
29 * from: svr4_util.c,v 1.5 1995/01/22 23:44:50 christos Exp
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/compat/linux/linux_util.c 179486 2008-06-02 08:40:06Z ed $");
33__FBSDID("$FreeBSD: head/sys/compat/linux/linux_util.c 184205 2008-10-23 15:53:51Z des $");
34
35#include "opt_compat.h"
36
37#include <sys/param.h>
38#include <sys/bus.h>
39#include <sys/fcntl.h>
40#include <sys/lock.h>
41#include <sys/malloc.h>

--- 118 unchanged lines hidden (view full) ---

160char *
161linux_get_char_devices()
162{
163 struct device_element *de;
164 char *temp, *string, *last;
165 char formated[256];
166 int current_size = 0, string_size = 1024;
167
34
35#include "opt_compat.h"
36
37#include <sys/param.h>
38#include <sys/bus.h>
39#include <sys/fcntl.h>
40#include <sys/lock.h>
41#include <sys/malloc.h>

--- 118 unchanged lines hidden (view full) ---

160char *
161linux_get_char_devices()
162{
163 struct device_element *de;
164 char *temp, *string, *last;
165 char formated[256];
166 int current_size = 0, string_size = 1024;
167
168 MALLOC(string, char *, string_size, M_LINUX, M_WAITOK);
168 string = malloc(string_size, M_LINUX, M_WAITOK);
169 string[0] = '\000';
170 last = "";
171 TAILQ_FOREACH(de, &devices, list) {
172 if (!de->entry.linux_char_device)
173 continue;
174 temp = string;
175 if (strcmp(last, de->entry.bsd_driver_name) != 0) {
176 last = de->entry.bsd_driver_name;
177
178 snprintf(formated, sizeof(formated), "%3d %s\n",
179 de->entry.linux_major,
180 de->entry.linux_device_name);
181 if (strlen(formated) + current_size
182 >= string_size) {
183 string_size *= 2;
169 string[0] = '\000';
170 last = "";
171 TAILQ_FOREACH(de, &devices, list) {
172 if (!de->entry.linux_char_device)
173 continue;
174 temp = string;
175 if (strcmp(last, de->entry.bsd_driver_name) != 0) {
176 last = de->entry.bsd_driver_name;
177
178 snprintf(formated, sizeof(formated), "%3d %s\n",
179 de->entry.linux_major,
180 de->entry.linux_device_name);
181 if (strlen(formated) + current_size
182 >= string_size) {
183 string_size *= 2;
184 MALLOC(string, char *, string_size,
184 string = malloc(string_size,
185 M_LINUX, M_WAITOK);
186 bcopy(temp, string, current_size);
185 M_LINUX, M_WAITOK);
186 bcopy(temp, string, current_size);
187 FREE(temp, M_LINUX);
187 free(temp, M_LINUX);
188 }
189 strcat(string, formated);
190 current_size = strlen(string);
191 }
192 }
193
194 return string;
195}
196
197void
198linux_free_get_char_devices(char *string)
199{
188 }
189 strcat(string, formated);
190 current_size = strlen(string);
191 }
192 }
193
194 return string;
195}
196
197void
198linux_free_get_char_devices(char *string)
199{
200 FREE(string, M_LINUX);
200 free(string, M_LINUX);
201}
202
203static int linux_major_starting = 200;
204
205int
206linux_device_register_handler(struct linux_device_handler *d)
207{
208 struct device_element *de;
209
210 if (d == NULL)
211 return (EINVAL);
212
201}
202
203static int linux_major_starting = 200;
204
205int
206linux_device_register_handler(struct linux_device_handler *d)
207{
208 struct device_element *de;
209
210 if (d == NULL)
211 return (EINVAL);
212
213 MALLOC(de, struct device_element *, sizeof(*de),
213 de = malloc(sizeof(*de),
214 M_LINUX, M_WAITOK);
215 if (d->linux_major < 0) {
216 d->linux_major = linux_major_starting++;
217 }
218 bcopy(d, &de->entry, sizeof(*d));
219
220 /* Add the element to the list, sorted on span. */
221 TAILQ_INSERT_TAIL(&devices, de, list);

--- 7 unchanged lines hidden (view full) ---

229 struct device_element *de;
230
231 if (d == NULL)
232 return (EINVAL);
233
234 TAILQ_FOREACH(de, &devices, list) {
235 if (bcmp(d, &de->entry, sizeof(*d)) == 0) {
236 TAILQ_REMOVE(&devices, de, list);
214 M_LINUX, M_WAITOK);
215 if (d->linux_major < 0) {
216 d->linux_major = linux_major_starting++;
217 }
218 bcopy(d, &de->entry, sizeof(*d));
219
220 /* Add the element to the list, sorted on span. */
221 TAILQ_INSERT_TAIL(&devices, de, list);

--- 7 unchanged lines hidden (view full) ---

229 struct device_element *de;
230
231 if (d == NULL)
232 return (EINVAL);
233
234 TAILQ_FOREACH(de, &devices, list) {
235 if (bcmp(d, &de->entry, sizeof(*d)) == 0) {
236 TAILQ_REMOVE(&devices, de, list);
237 FREE(de, M_LINUX);
237 free(de, M_LINUX);
238 return (0);
239 }
240 }
241
242 return (EINVAL);
243}
238 return (0);
239 }
240 }
241
242 return (EINVAL);
243}