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"
29 connect to a share - used when a tree_connect operation comes
30 in. For printing shares this should check that the spool directory
33 static NTSTATUS print_connect(struct ntvfs_module_context *ntvfs,
34 struct ntvfs_request *req, const char *sharename)
36 ntvfs->ctx->fs_type = talloc_strdup(ntvfs->ctx, "NTFS");
37 NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->fs_type);
39 ntvfs->ctx->dev_type = talloc_strdup(ntvfs->ctx, "LPT1:");
40 NT_STATUS_HAVE_NO_MEMORY(ntvfs->ctx->dev_type);
46 disconnect from a share
48 static NTSTATUS print_disconnect(struct ntvfs_module_context *ntvfs)
54 lots of operations are not allowed on printing shares - mostly return NT_STATUS_ACCESS_DENIED
56 static NTSTATUS print_unlink(struct ntvfs_module_context *ntvfs,
57 struct ntvfs_request *req,
58 union smb_unlink *unl)
60 return NT_STATUS_ACCESS_DENIED;
65 ioctl - used for job query
67 static NTSTATUS print_ioctl(struct ntvfs_module_context *ntvfs,
68 struct ntvfs_request *req, union smb_ioctl *io)
72 if (io->generic.level != RAW_IOCTL_IOCTL) {
73 return NT_STATUS_NOT_IMPLEMENTED;
76 if (io->ioctl.in.request == IOCTL_QUERY_JOB_INFO) {
78 /* a request for the print job id of an open print job */
79 io->ioctl.out.blob = data_blob_talloc(req, NULL, 32);
81 data_blob_clear(&io->ioctl.out.blob);
83 p = (char *)io->ioctl.out.blob.data;
84 SSVAL(p,0, 1 /* REWRITE: fsp->rap_print_jobid */);
85 push_string(p+2, lp_netbios_name(), 15, STR_TERMINATE|STR_ASCII);
86 push_string(p+18, ntvfs->ctx->config->name, 13, STR_TERMINATE|STR_ASCII);
90 return NT_STATUS_INVALID_PARAMETER;
95 initialialise the print backend, registering ourselves with the ntvfs subsystem
97 NTSTATUS ntvfs_print_init(void)
100 struct ntvfs_ops ops;
101 NTVFS_CURRENT_CRITICAL_SIZES(vers);
105 /* fill in the name and type */
106 ops.name = "default";
107 ops.type = NTVFS_PRINT;
109 /* fill in all the operations */
110 ops.connect = print_connect;
111 ops.disconnect = print_disconnect;
112 ops.unlink = print_unlink;
113 ops.ioctl = print_ioctl;
115 /* register ourselves with the NTVFS subsystem. We register under the name 'default'
116 as we wish to be the default backend */
117 ret = ntvfs_register(&ops, &vers);
119 if (!NT_STATUS_IS_OK(ret)) {
120 DEBUG(0,("Failed to register PRINT backend!\n"));