scm.c (c1f3ee120bb61045b1c0a3ead620d1d65af47130) scm.c (f8d570a4745835f2238a33b537218a1bb03fc671)
1/* scm.c - Socket level control messages processing.
2 *
3 * Author: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
4 * Alignment and value checking mods by Craig Metz
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

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

70 return -EINVAL;
71
72 if (!fpl)
73 {
74 fpl = kmalloc(sizeof(struct scm_fp_list), GFP_KERNEL);
75 if (!fpl)
76 return -ENOMEM;
77 *fplp = fpl;
1/* scm.c - Socket level control messages processing.
2 *
3 * Author: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
4 * Alignment and value checking mods by Craig Metz
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version

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

70 return -EINVAL;
71
72 if (!fpl)
73 {
74 fpl = kmalloc(sizeof(struct scm_fp_list), GFP_KERNEL);
75 if (!fpl)
76 return -ENOMEM;
77 *fplp = fpl;
78 INIT_LIST_HEAD(&fpl->list);
78 fpl->count = 0;
79 }
80 fpp = &fpl->fp[fpl->count];
81
82 if (fpl->count + num > SCM_MAX_FD)
83 return -EINVAL;
84
85 /*

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

101
102void __scm_destroy(struct scm_cookie *scm)
103{
104 struct scm_fp_list *fpl = scm->fp;
105 int i;
106
107 if (fpl) {
108 scm->fp = NULL;
79 fpl->count = 0;
80 }
81 fpp = &fpl->fp[fpl->count];
82
83 if (fpl->count + num > SCM_MAX_FD)
84 return -EINVAL;
85
86 /*

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

102
103void __scm_destroy(struct scm_cookie *scm)
104{
105 struct scm_fp_list *fpl = scm->fp;
106 int i;
107
108 if (fpl) {
109 scm->fp = NULL;
109 for (i=fpl->count-1; i>=0; i--)
110 fput(fpl->fp[i]);
111 kfree(fpl);
110 if (current->scm_work_list) {
111 list_add_tail(&fpl->list, current->scm_work_list);
112 } else {
113 LIST_HEAD(work_list);
114
115 current->scm_work_list = &work_list;
116
117 list_add(&fpl->list, &work_list);
118 while (!list_empty(&work_list)) {
119 fpl = list_first_entry(&work_list, struct scm_fp_list, list);
120
121 list_del(&fpl->list);
122 for (i=fpl->count-1; i>=0; i--)
123 fput(fpl->fp[i]);
124 kfree(fpl);
125 }
126
127 current->scm_work_list = NULL;
128 }
112 }
113}
114
115int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
116{
117 struct cmsghdr *cmsg;
118 int err;
119

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

279 struct scm_fp_list *new_fpl;
280 int i;
281
282 if (!fpl)
283 return NULL;
284
285 new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL);
286 if (new_fpl) {
129 }
130}
131
132int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *p)
133{
134 struct cmsghdr *cmsg;
135 int err;
136

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

296 struct scm_fp_list *new_fpl;
297 int i;
298
299 if (!fpl)
300 return NULL;
301
302 new_fpl = kmalloc(sizeof(*fpl), GFP_KERNEL);
303 if (new_fpl) {
304 INIT_LIST_HEAD(&new_fpl->list);
287 for (i=fpl->count-1; i>=0; i--)
288 get_file(fpl->fp[i]);
289 memcpy(new_fpl, fpl, sizeof(*fpl));
290 }
291 return new_fpl;
292}
293
294EXPORT_SYMBOL(__scm_destroy);
295EXPORT_SYMBOL(__scm_send);
296EXPORT_SYMBOL(put_cmsg);
297EXPORT_SYMBOL(scm_detach_fds);
298EXPORT_SYMBOL(scm_fp_dup);
305 for (i=fpl->count-1; i>=0; i--)
306 get_file(fpl->fp[i]);
307 memcpy(new_fpl, fpl, sizeof(*fpl));
308 }
309 return new_fpl;
310}
311
312EXPORT_SYMBOL(__scm_destroy);
313EXPORT_SYMBOL(__scm_send);
314EXPORT_SYMBOL(put_cmsg);
315EXPORT_SYMBOL(scm_detach_fds);
316EXPORT_SYMBOL(scm_fp_dup);