2 * Server-side smb network file management
4 * Copyright (C) 1998 Alexandre Julliard
5 * Copyright (C) 2000, 2001, 2002 Mike McCormack
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * FIXME: if you can't find something to fix,
22 * you're not looking hard enough
33 #ifdef HAVE_SYS_ERRNO_H
34 #include <sys/errno.h>
37 #include <sys/types.h>
42 #include <sys/ioctl.h>
51 static void smb_dump( struct object *obj, int verbose );
52 static int smb_get_fd( struct object *obj );
53 static int smb_get_info( struct object *obj, struct get_file_info_reply *reply, int *flags );
54 static int smb_get_poll_events( struct object *obj );
55 static void destroy_smb(struct object *obj);
67 static const struct object_ops smb_ops =
69 sizeof(struct smb), /* size */
71 default_poll_add_queue, /* add_queue */
72 default_poll_remove_queue, /* remove_queue */
73 default_poll_signaled, /* signaled */
74 no_satisfied, /* satisfied */
75 smb_get_poll_events, /* get_poll_events */
76 default_poll_event, /* poll_event */
77 smb_get_fd, /* get_fd */
79 smb_get_info, /* get_file_info */
80 NULL, /* queue_async */
81 destroy_smb /* destroy */
84 static void destroy_smb( struct object *obj)
86 /* struct smb *smb = (struct smb *)obj; */
87 assert( obj->ops == &smb_ops );
90 static void smb_dump( struct object *obj, int verbose )
92 struct smb *smb = (struct smb *)obj;
93 assert( obj->ops == &smb_ops );
94 fprintf( stderr, "smb file with socket fd=%d \n", smb->obj.fd );
97 struct smb *get_smb_obj( struct process *process, obj_handle_t handle, unsigned int access )
99 return (struct smb *)get_handle_obj( process, handle, access, &smb_ops );
102 static int smb_get_poll_events( struct object *obj )
104 /* struct smb *smb = (struct smb *)obj; */
106 assert( obj->ops == &smb_ops );
110 /* fprintf(stderr,"poll events are %04x\n",events); */
115 static int smb_get_fd( struct object *obj )
117 struct smb *smb = (struct smb *)obj;
118 assert( obj->ops == &smb_ops );
122 static int smb_get_info( struct object *obj, struct get_file_info_reply *reply, int *flags )
124 /* struct smb *smb = (struct smb *) obj; */
125 assert( obj->ops == &smb_ops );
129 reply->type = FILE_TYPE_CHAR;
131 reply->access_time = 0;
132 reply->write_time = 0;
133 reply->size_high = 0;
136 reply->index_high = 0;
137 reply->index_low = 0;
147 DECL_HANDLER(create_smb)
154 fd = thread_get_inflight_fd( current, req->fd );
157 set_error( STATUS_INVALID_HANDLE );
161 smb = alloc_object( &smb_ops, fd );
164 smb->tree_id = req->tree_id;
165 smb->user_id = req->user_id;
166 smb->dialect = req->dialect;
167 smb->file_id = req->file_id;
169 reply->handle = alloc_handle( current->process, smb, GENERIC_READ, 0);
170 release_object( smb );
174 DECL_HANDLER(get_smb_info)
178 if ((smb = get_smb_obj( current->process, req->handle, 0 )))
180 if(req->flags & SMBINFO_SET_OFFSET)
181 smb->offset = req->offset;
183 reply->tree_id = smb->tree_id;
184 reply->user_id = smb->user_id;
185 reply->dialect = smb->dialect;
186 reply->file_id = smb->file_id;
187 reply->offset = smb->offset;
189 release_object( smb );