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/smb/smb_constants.h"
26 #include "ntvfs/ntvfs.h"
27 #include "param/param.h"
29 NTSTATUS
ntvfs_print_init(void);
32 connect to a share - used when a tree_connect operation comes
33 in. For printing shares this should check that the spool directory
36 static NTSTATUS
print_connect(struct ntvfs_module_context
*ntvfs
,
37 struct ntvfs_request
*req
, union smb_tcon
* tcon
)
39 ntvfs
->ctx
->fs_type
= talloc_strdup(ntvfs
->ctx
, "NTFS");
40 NT_STATUS_HAVE_NO_MEMORY(ntvfs
->ctx
->fs_type
);
42 ntvfs
->ctx
->dev_type
= talloc_strdup(ntvfs
->ctx
, "LPT1:");
43 NT_STATUS_HAVE_NO_MEMORY(ntvfs
->ctx
->dev_type
);
45 if (tcon
->generic
.level
== RAW_TCON_TCONX
) {
46 tcon
->tconx
.out
.fs_type
= ntvfs
->ctx
->fs_type
;
47 tcon
->tconx
.out
.dev_type
= ntvfs
->ctx
->dev_type
;
54 disconnect from a share
56 static NTSTATUS
print_disconnect(struct ntvfs_module_context
*ntvfs
)
62 lots of operations are not allowed on printing shares - mostly return NT_STATUS_ACCESS_DENIED
64 static NTSTATUS
print_unlink(struct ntvfs_module_context
*ntvfs
,
65 struct ntvfs_request
*req
,
66 union smb_unlink
*unl
)
68 return NT_STATUS_ACCESS_DENIED
;
73 ioctl - used for job query
75 static NTSTATUS
print_ioctl(struct ntvfs_module_context
*ntvfs
,
76 struct ntvfs_request
*req
, union smb_ioctl
*io
)
80 if (io
->generic
.level
!= RAW_IOCTL_IOCTL
) {
81 return NT_STATUS_NOT_IMPLEMENTED
;
84 if (io
->ioctl
.in
.request
== IOCTL_QUERY_JOB_INFO
) {
86 /* a request for the print job id of an open print job */
87 io
->ioctl
.out
.blob
= data_blob_talloc(req
, NULL
, 32);
89 data_blob_clear(&io
->ioctl
.out
.blob
);
91 p
= (char *)io
->ioctl
.out
.blob
.data
;
92 SSVAL(p
,0, 1 /* REWRITE: fsp->rap_print_jobid */);
93 push_string(p
+2, lpcfg_netbios_name(ntvfs
->ctx
->lp_ctx
), 15, STR_TERMINATE
|STR_ASCII
);
94 push_string(p
+18, ntvfs
->ctx
->config
->name
, 13, STR_TERMINATE
|STR_ASCII
);
98 return NT_STATUS_INVALID_PARAMETER
;
103 initialialise the print backend, registering ourselves with the ntvfs subsystem
105 NTSTATUS
ntvfs_print_init(void)
108 struct ntvfs_ops ops
;
109 NTVFS_CURRENT_CRITICAL_SIZES(vers
);
113 /* fill in the name and type */
114 ops
.name
= "default";
115 ops
.type
= NTVFS_PRINT
;
117 /* fill in all the operations */
118 ops
.connect_fn
= print_connect
;
119 ops
.disconnect_fn
= print_disconnect
;
120 ops
.unlink_fn
= print_unlink
;
121 ops
.ioctl_fn
= print_ioctl
;
123 /* register ourselves with the NTVFS subsystem. We register under the name 'default'
124 as we wish to be the default backend */
125 ret
= ntvfs_register(&ops
, &vers
);
127 if (!NT_STATUS_IS_OK(ret
)) {
128 DEBUG(0,("Failed to register PRINT backend!\n"));