2 Unix SMB/CIFS implementation.
3 default print NTVFS backend
4 Copyright (C) Andrew Tridgell 2003
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 this implements the print backend, called by the NTVFS subsystem to
21 handle requests on printing shares
25 #include "libcli/raw/ioctl.h"
26 #include "ntvfs/ntvfs.h"
27 #include "param/param.h"
30 connect to a share - used when a tree_connect operation comes
31 in. For printing shares this should check that the spool directory
34 static NTSTATUS print_connect(struct ntvfs_module_context *ntvfs,
35 struct ntvfs_request *req, const char *sharename)
37 ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
38 NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
40 ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "LPT1:");
41 NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
47 disconnect from a share
49 static NTSTATUS print_disconnect(struct ntvfs_module_context *ntvfs)
55 lots of operations are not allowed on printing shares - mostly return NT_STATUS_ACCESS_DENIED
57 static NTSTATUS print_unlink(struct ntvfs_module_context *ntvfs,
58 struct ntvfs_request *req,
59 union smb_unlink *unl)
61 return NT_STATUS_ACCESS_DENIED;
66 ioctl - used for job query
68 static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs,
69 struct ntvfs_request *req, union smb_ioctl *io)
73 if (io->generic.level != RAW_IOCTL_IOCTL) {
74 return NT_STATUS_NOT_IMPLEMENTED;
77 if (io->ioctl.in.request == IOCTL_QUERY_JOB_INFO) {
79 /* a request for the print job id of an open print job */
80 io->ioctl.out.blob = data_blob_talloc(req, NULL, 32);
82 data_blob_clear(&io->ioctl.out.blob);
84 p = (char *)io->ioctl.out.blob.data;
85 SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */);
86 push_string(p+2, lp_netbios_name(global_loadparm), 15, STR_TERMINATE|STR_ASCII);
87 push_string(p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
91 return NT_STATUS_INVALID_PARAMETER;
96 initialialise the print backend, registering ourselves with the ntvfs subsystem
98 NTSTATUS ntvfs_print_init(void)
101 struct ntvfs_ops ops;
102 NTVFS_CURRENT_CRITICAL_SIZES(vers);
106 /* fill in the name and type */
107 ops.name = "default";
108 ops.type = NTVFS_PRINT;
110 /* fill in all the operations */
111 ops.connect = print_connect;
112 ops.disconnect = print_disconnect;
113 ops.unlink = print_unlink;
114 ops.ioctl = print_ioctl;
116 /* register ourselves with the NTVFS subsystem. We register under the name 'default'
117 as we wish to be the default backend */
118 ret = ntvfs_register(&ops, &vers);
120 if (!NT_STATUS_IS_OK(ret)) {
121 DEBUG(0,("Failed to register PRINT backend!\n"));