1da6c28aaSamw /* 2da6c28aaSamw * CDDL HEADER START 3da6c28aaSamw * 4da6c28aaSamw * The contents of this file are subject to the terms of the 5da6c28aaSamw * Common Development and Distribution License (the "License"). 6da6c28aaSamw * You may not use this file except in compliance with the License. 7da6c28aaSamw * 8da6c28aaSamw * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9da6c28aaSamw * or http://www.opensolaris.org/os/licensing. 10da6c28aaSamw * See the License for the specific language governing permissions 11da6c28aaSamw * and limitations under the License. 12da6c28aaSamw * 13da6c28aaSamw * When distributing Covered Code, include this CDDL HEADER in each 14da6c28aaSamw * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15da6c28aaSamw * If applicable, add the following below this CDDL HEADER, with the 16da6c28aaSamw * fields enclosed by brackets "[]" replaced with your own identifying 17da6c28aaSamw * information: Portions Copyright [yyyy] [name of copyright owner] 18da6c28aaSamw * 19da6c28aaSamw * CDDL HEADER END 20da6c28aaSamw */ 21148c5f43SAlan Wright 22da6c28aaSamw /* 23148c5f43SAlan Wright * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 24da6c28aaSamw */ 25da6c28aaSamw 26da6c28aaSamw /* 279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Net DFS server side RPC service for managing DFS namespaces. 289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * For more details refer to following Microsoft specification: 309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM] 319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Distributed File System (DFS): Namespace Management Protocol Specification 32da6c28aaSamw */ 33da6c28aaSamw 349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <unistd.h> 359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <libgen.h> 36da6c28aaSamw #include <strings.h> 379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <sys/sysmacros.h> 38da6c28aaSamw 399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <smbsrv/libmlsvc.h> 40148c5f43SAlan Wright #include <smbsrv/nmpipes.h> 41148c5f43SAlan Wright #include <smbsrv/ndl/netdfs.ndl> 429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #include <dfs.h> 43da6c28aaSamw 449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Depends on the information level requested around 4000 or more links 469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * can be provided with this buffer size. The limitation here is due 479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * to some problem in NDR and/or opipe layer so: 489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * - Do NOT increase the buffer size until that problem is fixed 509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * - The buffer size should be increased when the problem is fixed 519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * so the 4000 link limitation is removed. 529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define NETDFS_MAXBUFLEN (800 * 1024) 549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States #define NETDFS_MAXPREFLEN ((uint32_t)(-1)) 55da6c28aaSamw 569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States typedef struct netdfs_enumhandle_t { 579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t de_level; /* level of detail being requested */ 589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t de_prefmaxlen; /* client MAX size buffer preference */ 599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t de_resume; /* client resume handle */ 609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t de_bavail; /* remaining buffer space in bytes */ 619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t de_ntotal; /* total number of objects */ 629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t de_nmax; /* MAX number of objects to return */ 639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t de_nitems; /* number of objects in buf */ 649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t de_nskip; /* number of objects to skip */ 659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *de_entries; /* ndr buffer */ 669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } netdfs_enumhandle_t; 67da6c28aaSamw 688d7e4166Sjose borrego static int netdfs_s_getver(void *, ndr_xa_t *); 698d7e4166Sjose borrego static int netdfs_s_add(void *, ndr_xa_t *); 708d7e4166Sjose borrego static int netdfs_s_remove(void *, ndr_xa_t *); 718d7e4166Sjose borrego static int netdfs_s_setinfo(void *, ndr_xa_t *); 728d7e4166Sjose borrego static int netdfs_s_getinfo(void *, ndr_xa_t *); 738d7e4166Sjose borrego static int netdfs_s_enum(void *, ndr_xa_t *); 748d7e4166Sjose borrego static int netdfs_s_move(void *, ndr_xa_t *); 758d7e4166Sjose borrego static int netdfs_s_rename(void *, ndr_xa_t *); 768d7e4166Sjose borrego static int netdfs_s_addstdroot(void *, ndr_xa_t *); 778d7e4166Sjose borrego static int netdfs_s_remstdroot(void *, ndr_xa_t *); 788d7e4166Sjose borrego static int netdfs_s_enumex(void *, ndr_xa_t *); 79da6c28aaSamw 809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_setinfo_100(dfs_path_t *, netdfs_info100_t *); 819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_setinfo_101(dfs_path_t *, netdfs_info101_t *, 829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *, const char *); 839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_setinfo_102(dfs_path_t *, netdfs_info102_t *); 849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_setinfo_103(dfs_path_t *, netdfs_info103_t *); 859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_setinfo_104(dfs_path_t *, netdfs_info104_t *, 869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *, const char *); 879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_setinfo_105(dfs_path_t *, netdfs_info105_t *); 889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_info_1(netdfs_info1_t *, dfs_info_t *, ndr_xa_t *, 909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *); 919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_info_2(netdfs_info2_t *, dfs_info_t *, ndr_xa_t *, 929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *); 939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_info_3(netdfs_info3_t *, dfs_info_t *, ndr_xa_t *, 949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *); 959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_info_4(netdfs_info4_t *, dfs_info_t *, ndr_xa_t *, 969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *); 979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_info_5(netdfs_info5_t *, dfs_info_t *, ndr_xa_t *, 989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *); 999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_info_6(netdfs_info6_t *, dfs_info_t *, ndr_xa_t *, 1009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *); 1019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_info_100(netdfs_info100_t *, dfs_info_t *, ndr_xa_t *, 1029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *); 1039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_info_300(netdfs_info300_t *, dfs_info_t *, ndr_xa_t *, 1049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *); 1059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t netdfs_enum_common(netdfs_enumhandle_t *, ndr_xa_t *); 1079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static void netdfs_path_create(const char *); 1099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static void netdfs_path_remove(smb_unc_t *); 1109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static boolean_t netdfs_guid_fromstr(char *, netdfs_uuid_t *); 1119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1128d7e4166Sjose borrego static ndr_stub_table_t netdfs_stub_table[] = { 113da6c28aaSamw { netdfs_s_getver, NETDFS_OPNUM_GETVER }, 114da6c28aaSamw { netdfs_s_add, NETDFS_OPNUM_ADD }, 115da6c28aaSamw { netdfs_s_remove, NETDFS_OPNUM_REMOVE }, 116da6c28aaSamw { netdfs_s_setinfo, NETDFS_OPNUM_SETINFO }, 117da6c28aaSamw { netdfs_s_getinfo, NETDFS_OPNUM_GETINFO }, 118da6c28aaSamw { netdfs_s_enum, NETDFS_OPNUM_ENUM }, 119da6c28aaSamw { netdfs_s_rename, NETDFS_OPNUM_RENAME }, 120da6c28aaSamw { netdfs_s_move, NETDFS_OPNUM_MOVE }, 121da6c28aaSamw { netdfs_s_addstdroot, NETDFS_OPNUM_ADDSTDROOT }, 122da6c28aaSamw { netdfs_s_remstdroot, NETDFS_OPNUM_REMSTDROOT }, 123da6c28aaSamw { netdfs_s_enumex, NETDFS_OPNUM_ENUMEX }, 124da6c28aaSamw {0} 125da6c28aaSamw }; 126da6c28aaSamw 1278d7e4166Sjose borrego static ndr_service_t netdfs_service = { 128da6c28aaSamw "NETDFS", /* name */ 129da6c28aaSamw "DFS", /* desc */ 1309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States "\\netdfs", /* endpoint */ 1319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States PIPE_NETDFS, /* sec_addr_port */ 132da6c28aaSamw NETDFS_ABSTRACT_UUID, NETDFS_ABSTRACT_VERS, 133da6c28aaSamw NETDFS_TRANSFER_UUID, NETDFS_TRANSFER_VERS, 134da6c28aaSamw 135da6c28aaSamw 0, /* no bind_instance_size */ 136da6c28aaSamw 0, /* no bind_req() */ 137da6c28aaSamw 0, /* no unbind_and_close() */ 138da6c28aaSamw 0, /* use generic_call_stub() */ 139da6c28aaSamw 140da6c28aaSamw &TYPEINFO(netdfs_interface), /* interface ti */ 141da6c28aaSamw netdfs_stub_table /* stub_table */ 142da6c28aaSamw }; 143da6c28aaSamw 144da6c28aaSamw /* 145da6c28aaSamw * Register the NETDFS RPC interface with the RPC runtime library. 146da6c28aaSamw * The service must be registered in order to use either the client 147da6c28aaSamw * side or the server side functions. 148da6c28aaSamw */ 149da6c28aaSamw void 150da6c28aaSamw netdfs_initialize(void) 151da6c28aaSamw { 1528d7e4166Sjose borrego (void) ndr_svc_register(&netdfs_service); 1539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_init(); 1549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 1569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void 1579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_finalize(void) 1589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 1599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_fini(); 160da6c28aaSamw } 161da6c28aaSamw 162da6c28aaSamw /* 1639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Returns the version number of the DFS server in use on the server. 164da6c28aaSamw * 1659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsManagerGetVersion (Opnum 0) 166da6c28aaSamw */ 167da6c28aaSamw /*ARGSUSED*/ 168da6c28aaSamw static int 1698d7e4166Sjose borrego netdfs_s_getver(void *arg, ndr_xa_t *mxa) 170da6c28aaSamw { 171da6c28aaSamw struct netdfs_getver *param = arg; 172da6c28aaSamw 1739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->version = DFS_MANAGER_VERSION_NT4; 1748d7e4166Sjose borrego return (NDR_DRC_OK); 175da6c28aaSamw } 176da6c28aaSamw 177da6c28aaSamw /* 1789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Creates a new DFS link or adds a new target to an existing link of a 1799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * DFS namespace. 1809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 1819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsAdd (Opnum 1) 182da6c28aaSamw */ 183da6c28aaSamw static int 1848d7e4166Sjose borrego netdfs_s_add(void *arg, ndr_xa_t *mxa) 185da6c28aaSamw { 1869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_add_t *param = arg; 1879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_t path; 1889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status; 1899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *uncpath = (const char *)param->dfs_path; 1909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *fspath = (const char *)path.p_fspath; 1919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States boolean_t newlink; 192da6c28aaSamw 1939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!ndr_is_admin(mxa)) { 194da6c28aaSamw param->status = ERROR_ACCESS_DENIED; 1958d7e4166Sjose borrego return (NDR_DRC_OK); 196da6c28aaSamw } 197da6c28aaSamw 1989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (param->server == NULL || param->share == NULL) { 1999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_PARAMETER; 2009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 2019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States switch (param->flags) { 2049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case DFS_CREATE_VOLUME: 2059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case DFS_ADD_VOLUME: 2069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case DFS_RESTORE_VOLUME: 2079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case (DFS_ADD_VOLUME | DFS_RESTORE_VOLUME): 2089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 2099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States default: 2109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_PARAMETER; 2119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 2129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_path_parse(&path, uncpath, DFS_OBJECT_LINK); 2159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) { 2169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 2179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 2189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = smb_name_validate_rpath(path.p_unc.unc_path); 2219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) { 2229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_free(&path); 2239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 2249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 2259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_ON); 2289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_path_create(fspath); 2309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_add(fspath, (const char *)param->server, 2329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (const char *)param->share, (const char *)param->comment, 2339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->flags, &newlink); 2349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (newlink) 2369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) dfs_cache_add_byname(path.p_unc.unc_share, 2379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States path.p_unc.unc_path, DFS_OBJECT_LINK); 2389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) 2409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_path_remove(&path.p_unc); 2419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_OFF); 2439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_free(&path); 2459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 2469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 2479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 249da6c28aaSamw /* 2509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Removes a link or a link target from a DFS namespace. A link can be 2519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * removed regardless of the number of targets associated with it. 252da6c28aaSamw * 2539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsRemove (Opnum 2) 254da6c28aaSamw */ 255da6c28aaSamw static int 2568d7e4166Sjose borrego netdfs_s_remove(void *arg, ndr_xa_t *mxa) 257da6c28aaSamw { 258da6c28aaSamw struct netdfs_remove *param = arg; 2599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_t path; 2609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status, stat; 2619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *uncpath = (const char *)param->dfs_path; 2629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *fspath = (const char *)path.p_fspath; 263da6c28aaSamw 2649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!ndr_is_admin(mxa)) { 265da6c28aaSamw param->status = ERROR_ACCESS_DENIED; 2668d7e4166Sjose borrego return (NDR_DRC_OK); 267da6c28aaSamw } 268da6c28aaSamw 2699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* both server and share must be NULL or non-NULL */ 2709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((param->server == NULL && param->share != NULL) || 2719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (param->server != NULL && param->share == NULL)) { 2729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_PARAMETER; 2739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 2749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_path_parse(&path, uncpath, DFS_OBJECT_LINK); 2779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) { 2789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 2799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 2809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_ON); 2839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_remove(fspath, (const char *)param->server, 2859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (const char *)param->share); 2869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 2879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status == ERROR_SUCCESS) { 2889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (dfs_link_stat(fspath, &stat) == ERROR_SUCCESS) { 2899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (stat != DFS_STAT_ISDFS) 2909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_cache_remove(path.p_unc.unc_share, 2919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States path.p_unc.unc_path); 292da6c28aaSamw /* 2939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * if link is removed then try to remove its 2949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * empty parent directories if any 2959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 2969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (stat == DFS_STAT_NOTFOUND) 2979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_path_remove(&path.p_unc); 2989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 2999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 3009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_OFF); 3029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_free(&path); 3049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 3059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 3069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 3079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 3099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets or modifies information relevant to a specific DFS root, DFS root 3109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * target, DFS link, or DFS link target 311da6c28aaSamw * 3129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsSetInfo (Opnum 3) 313da6c28aaSamw */ 314da6c28aaSamw /*ARGSUSED*/ 315da6c28aaSamw static int 3168d7e4166Sjose borrego netdfs_s_setinfo(void *arg, ndr_xa_t *mxa) 317da6c28aaSamw { 3189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_setinfo_t *param = arg; 3199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_t path; 3209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status, stat; 321da6c28aaSamw 3229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* both server and share must be NULL or non-NULL */ 3239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((param->server == NULL && param->share != NULL) || 3249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (param->server != NULL && param->share == NULL)) { 325da6c28aaSamw param->status = ERROR_INVALID_PARAMETER; 3268d7e4166Sjose borrego return (NDR_DRC_OK); 327da6c28aaSamw } 328da6c28aaSamw 3299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_path_parse(&path, (const char *)param->dfs_path, 3309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States DFS_OBJECT_ANY); 3319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) { 3339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 3349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 335da6c28aaSamw } 336da6c28aaSamw 3379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_ON); 3389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_stat((const char *)path.p_fspath, &stat); 3399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 3409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((path.p_type == DFS_OBJECT_LINK) && (stat != DFS_STAT_ISDFS)) { 3419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_OFF); 3429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_free(&path); 3439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_NOT_FOUND; 3448d7e4166Sjose borrego return (NDR_DRC_OK); 345da6c28aaSamw } 346da6c28aaSamw 347da6c28aaSamw switch (param->info.level) { 348da6c28aaSamw case 100: 3499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_setinfo_100(&path, param->info.iu.info100); 350da6c28aaSamw break; 3519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 101: 3529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_setinfo_101(&path, param->info.iu.info101, 3539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (const char *)param->server, (const char *)param->share); 3549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 3559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 102: 3569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_setinfo_102(&path, param->info.iu.info102); 3579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 3589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 103: 3599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_setinfo_103(&path, param->info.iu.info103); 3609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 3619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 104: 3629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_setinfo_104(&path, param->info.iu.info104, 3639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (const char *)param->server, (const char *)param->share); 3649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 3659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 105: 3669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_setinfo_105(&path, param->info.iu.info105); 3679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 368da6c28aaSamw default: 3699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_INVALID_LEVEL; 3709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 371da6c28aaSamw } 372da6c28aaSamw 3739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_OFF); 3749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_free(&path); 375da6c28aaSamw param->status = status; 3768d7e4166Sjose borrego return (NDR_DRC_OK); 377da6c28aaSamw } 378da6c28aaSamw 3799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 3809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Returns information about a DFS root or a DFS link of the specified 3819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * DFS namespace. 3829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 3839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsGetInfo (Opnum 4) 3849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 3859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static int 3869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_s_getinfo(void *arg, ndr_xa_t *mxa) 3879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 3889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_getinfo_t *param = arg; 3899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info1_t *info1; 3909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info2_t *info2; 3919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info3_t *info3; 3929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info4_t *info4; 3939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info5_t *info5; 3949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info6_t *info6; 3959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info100_t *info100; 3969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_t info; 3979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_t path; 3989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status, stat; 3999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *fspath; 4009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t level = param->level; 4019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_path_parse(&path, (const char *)param->dfs_path, 4039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States DFS_OBJECT_ANY); 4049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) 4069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto getinfo_error; 4079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_ON); 4099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States fspath = path.p_fspath; 4119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (path.p_type == DFS_OBJECT_LINK) { 4129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_stat(fspath, &stat); 4139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status != ERROR_SUCCESS) || (stat != DFS_STAT_ISDFS)) { 4149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_NOT_FOUND; 4159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto getinfo_error; 4169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_getinfo(fspath, &info, param->level); 4199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } else { 4209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_root_getinfo(fspath, &info, param->level); 4219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) 4249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto getinfo_error; 4259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(info.i_uncpath, (char *)param->dfs_path, 4279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States sizeof (info.i_uncpath)); 4289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_trace("netdfs_s_getinfo", &info); 4309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_NOT_ENOUGH_MEMORY; 4329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States switch (level) { 434da6c28aaSamw case 1: 4359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((info1 = NDR_NEW(mxa, netdfs_info1_t)) != NULL) { 4369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.iu.info1 = info1; 4379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_1(info1, &info, mxa, NULL); 4389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 440da6c28aaSamw case 2: 4419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((info2 = NDR_NEW(mxa, netdfs_info2_t)) != NULL) { 4429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.iu.info2 = info2; 4439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_2(info2, &info, mxa, NULL); 4449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 446da6c28aaSamw case 3: 4479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((info3 = NDR_NEW(mxa, netdfs_info3_t)) != NULL) { 4489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.iu.info3 = info3; 4499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_3(info3, &info, mxa, NULL); 4509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 452da6c28aaSamw case 4: 4539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((info4 = NDR_NEW(mxa, netdfs_info4_t)) != NULL) { 4549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.iu.info4 = info4; 4559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_4(info4, &info, mxa, NULL); 4569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 4589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 5: 4599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((info5 = NDR_NEW(mxa, netdfs_info5_t)) != NULL) { 4609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.iu.info5 = info5; 4619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_5(info5, &info, mxa, NULL); 4629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 4649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 6: 4659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((info6 = NDR_NEW(mxa, netdfs_info6_t)) != NULL) { 4669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.iu.info6 = info6; 4679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_6(info6, &info, mxa, NULL); 4689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 4699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 470da6c28aaSamw case 100: 4719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((info100 = NDR_NEW(mxa, netdfs_info100_t)) != NULL) { 4729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.iu.info100 = info100; 4739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_100(info100, &info, mxa, NULL); 4749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 475da6c28aaSamw break; 476da6c28aaSamw 477da6c28aaSamw default: 4789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_INVALID_LEVEL; 4799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 480da6c28aaSamw } 481da6c28aaSamw 4829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_free(&info); 4839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States getinfo_error: 4859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_OFF); 4869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_path_free(&path); 4879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) 4889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(param, sizeof (netdfs_getinfo_t)); 4899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 4909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info.level = level; 4919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 4928d7e4166Sjose borrego return (NDR_DRC_OK); 493da6c28aaSamw } 494da6c28aaSamw 495da6c28aaSamw /* 4969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Enumerates the DFS root hosted on a server or the DFS links of the 4979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * namespace hosted by a server. Depending on the information level, 4989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * the targets of the root and links are also displayed. 499da6c28aaSamw * 5009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * For unsupported levels, it should return ERROR_INVALID_LEVEL as 5019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Microsoft does for DFS server on Win2000 and NT. 5029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 5039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsEnum (Opnum 5) 504da6c28aaSamw */ 505da6c28aaSamw /*ARGSUSED*/ 506da6c28aaSamw static int 5078d7e4166Sjose borrego netdfs_s_enum(void *arg, ndr_xa_t *mxa) 508da6c28aaSamw { 5099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_enum_t *param = arg; 5109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_enumhandle_t de; 5119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t level = param->level; 5129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status = ERROR_SUCCESS; 5139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t nroot; 5149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States size_t entsize; 515da6c28aaSamw 5169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (param->info == NULL) { 5179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_INVALID_PARAMETER; 5189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 5199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((nroot = dfs_namespace_count()) == 0) 5229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_NOT_FOUND; 5239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else if (nroot > 1) 5249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_DEVICE_NOT_AVAILABLE; 5259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) 5279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 5289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&de, sizeof (netdfs_enumhandle_t)); 5309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_level = level; 5319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_ntotal = dfs_cache_num(); 5329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (param->pref_max_len == NETDFS_MAXPREFLEN || 5349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->pref_max_len > NETDFS_MAXBUFLEN) 5359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_prefmaxlen = NETDFS_MAXBUFLEN; 5369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else 5379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_prefmaxlen = param->pref_max_len; 5389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_bavail = de.de_prefmaxlen; 5409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (param->resume_handle != NULL) { 5429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (*param->resume_handle >= de.de_ntotal) { 5439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_NO_MORE_ITEMS; 5449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 5459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_resume = *param->resume_handle; 5479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_nskip = de.de_resume; 5489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *param->resume_handle = 0; 5499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_ON); 5529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_NOT_ENOUGH_MEMORY; 5549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States switch (level) { 556da6c28aaSamw case 1: 5579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entsize = sizeof (netdfs_info1_t); 5589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_nmax = MAX((de.de_prefmaxlen / entsize), 1); 5599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_entries = NDR_NEWN(mxa, netdfs_info1_t, de.de_nmax); 5609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de.de_entries == NULL) 5619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 5629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status = netdfs_enum_common(&de, mxa)) == ERROR_SUCCESS) { 5649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info1->info1 = de.de_entries; 5659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info1->count = de.de_nitems; 5669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 568da6c28aaSamw case 2: 5699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entsize = sizeof (netdfs_info2_t); 5709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_nmax = MAX((de.de_prefmaxlen / entsize), 1); 5719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_entries = NDR_NEWN(mxa, netdfs_info2_t, de.de_nmax); 5729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de.de_entries == NULL) 5739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 5749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status = netdfs_enum_common(&de, mxa)) == ERROR_SUCCESS) { 5769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info2->info2 = de.de_entries; 5779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info2->count = de.de_nitems; 5789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 580da6c28aaSamw case 3: 5819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entsize = sizeof (netdfs_info3_t) + 5829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States sizeof (netdfs_storage_info_t); 5839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_nmax = MAX((de.de_prefmaxlen / entsize), 1); 5849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_entries = NDR_NEWN(mxa, netdfs_info3_t, de.de_nmax); 5859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de.de_entries == NULL) 5869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 5879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 5889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status = netdfs_enum_common(&de, mxa)) == ERROR_SUCCESS) { 5899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info3->info3 = de.de_entries; 5909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info3->count = de.de_nitems; 5919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 5929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 5939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 4: 5949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entsize = sizeof (netdfs_info4_t) + 5959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States sizeof (netdfs_storage_info_t); 5969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_nmax = MAX((de.de_prefmaxlen / entsize), 1); 5979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_entries = NDR_NEWN(mxa, netdfs_info4_t, de.de_nmax); 5989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de.de_entries == NULL) 5999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 6009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 6019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status = netdfs_enum_common(&de, mxa)) == ERROR_SUCCESS) { 6029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info4->info4 = de.de_entries; 6039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info4->count = de.de_nitems; 6049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 6059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 6069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 6079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 5: 6089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entsize = sizeof (netdfs_info5_t); 6099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_nmax = MAX((de.de_prefmaxlen / entsize), 1); 6109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_entries = NDR_NEWN(mxa, netdfs_info5_t, de.de_nmax); 6119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de.de_entries == NULL) 6129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 6139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 6149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status = netdfs_enum_common(&de, mxa)) == ERROR_SUCCESS) { 6159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info5->info5 = de.de_entries; 6169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info5->count = de.de_nitems; 6179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 6189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 6199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 6209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 6: 6219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entsize = sizeof (netdfs_info6_t) + 6229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States sizeof (netdfs_storage_info1_t); 6239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_nmax = MAX((de.de_prefmaxlen / entsize), 1); 6249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_entries = NDR_NEWN(mxa, netdfs_info6_t, de.de_nmax); 6259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de.de_entries == NULL) 6269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 6279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 6289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status = netdfs_enum_common(&de, mxa)) == ERROR_SUCCESS) { 6299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info6->info6 = de.de_entries; 6309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info6->count = de.de_nitems; 6319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 6329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 6339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 6349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 300: 6359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entsize = sizeof (netdfs_info300_t); 6369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_nmax = MAX((de.de_prefmaxlen / entsize), 1); 6379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de.de_entries = NDR_NEWN(mxa, netdfs_info300_t, de.de_nmax); 6389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de.de_entries == NULL) 6399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States goto enum_error; 6409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 6419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status = netdfs_enum_common(&de, mxa)) == ERROR_SUCCESS) { 6429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info300->info300 = de.de_entries; 6439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->info->iu.info300->count = de.de_nitems; 6449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 645da6c28aaSamw break; 646da6c28aaSamw 647da6c28aaSamw default: 6489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_INVALID_PARAMETER; 6499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 650da6c28aaSamw } 651da6c28aaSamw 6529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status == ERROR_SUCCESS) && (param->resume_handle != NULL)) 6539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *param->resume_handle = de.de_resume; 6549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 6559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States enum_error: 6569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_OFF); 6579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = status; 6588d7e4166Sjose borrego return (NDR_DRC_OK); 659da6c28aaSamw } 660da6c28aaSamw 661da6c28aaSamw /* 6629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Renames or moves a DFS link 6639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 6649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Does not need to be supported for DFS version 1 6659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 6669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsMove (Opnum 6) 667da6c28aaSamw */ 668da6c28aaSamw /*ARGSUSED*/ 669da6c28aaSamw static int 6708d7e4166Sjose borrego netdfs_s_move(void *arg, ndr_xa_t *mxa) 671da6c28aaSamw { 672da6c28aaSamw struct netdfs_move *param = arg; 673da6c28aaSamw 6749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_NOT_SUPPORTED; 6758d7e4166Sjose borrego return (NDR_DRC_OK); 676da6c28aaSamw } 677da6c28aaSamw 678da6c28aaSamw /* 6799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * According to [MS-DFSNM] spec this operation (opnum 7) is not 6809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * used over the wire. 681da6c28aaSamw */ 682da6c28aaSamw /*ARGSUSED*/ 683da6c28aaSamw static int 6848d7e4166Sjose borrego netdfs_s_rename(void *arg, ndr_xa_t *mxa) 685da6c28aaSamw { 686da6c28aaSamw struct netdfs_rename *param = arg; 687da6c28aaSamw 6889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_NOT_SUPPORTED; 6898d7e4166Sjose borrego return (NDR_DRC_OK); 690da6c28aaSamw } 691da6c28aaSamw 692da6c28aaSamw /* 6939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Creates a new standalone DFS namespace 6949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 6959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsAddStdRoot (Opnum 12) 696da6c28aaSamw */ 697da6c28aaSamw /*ARGSUSED*/ 698da6c28aaSamw static int 6998d7e4166Sjose borrego netdfs_s_addstdroot(void *arg, ndr_xa_t *mxa) 700da6c28aaSamw { 701da6c28aaSamw struct netdfs_addstdroot *param = arg; 7029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *share = (const char *)param->share; 7039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *comment = (const char *)param->comment; 704da6c28aaSamw 7059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!ndr_is_admin(mxa)) { 7069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_ACCESS_DENIED; 7079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (NDR_DRC_OK); 7089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 7099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 7109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_ON); 7119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* For now only allow a single standalone namespace */ 712*cb174861Sjoyce mcintosh if (dfs_namespace_count() == 0) 7139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = dfs_namespace_add(share, comment); 714*cb174861Sjoyce mcintosh else 7159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_NOT_SUPPORTED; 7169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_OFF); 717*cb174861Sjoyce mcintosh 7188d7e4166Sjose borrego return (NDR_DRC_OK); 719da6c28aaSamw } 720da6c28aaSamw 721da6c28aaSamw /* 7229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Deletes the specified stand-alone DFS namespace. The DFS namespace can be 7239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * removed without first removing all of the links in it. 7249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 7259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM]: NetrDfsRemoveStdRoot (Opnum 13) 726da6c28aaSamw */ 727da6c28aaSamw /*ARGSUSED*/ 728da6c28aaSamw static int 7298d7e4166Sjose borrego netdfs_s_remstdroot(void *arg, ndr_xa_t *mxa) 730da6c28aaSamw { 731da6c28aaSamw struct netdfs_remstdroot *param = arg; 7329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *share = (const char *)param->share; 733da6c28aaSamw 7349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_ON); 7359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 736*cb174861Sjoyce mcintosh if (ndr_is_admin(mxa)) 7379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = dfs_namespace_remove(share); 738*cb174861Sjoyce mcintosh else 7399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_ACCESS_DENIED; 7409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 7419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_setpriv(PRIV_OFF); 7428d7e4166Sjose borrego return (NDR_DRC_OK); 743da6c28aaSamw } 744da6c28aaSamw 745da6c28aaSamw /* 7469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Enumerates the DFS roots hosted on a server, or DFS links of a namespace 7479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * hosted by the server. Depending on the information level, the targets 7489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * associated with the roots and links are also displayed 749da6c28aaSamw * 7509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Does not need to be supported for DFS version 1 7519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 7529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * [MS-DFSNM] NetrDfsEnumEx (Opnum 21) 753da6c28aaSamw */ 7549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /*ARGSUSED*/ 755da6c28aaSamw static int 7568d7e4166Sjose borrego netdfs_s_enumex(void *arg, ndr_xa_t *mxa) 757da6c28aaSamw { 758da6c28aaSamw struct netdfs_enumex *param = arg; 759da6c28aaSamw 760da6c28aaSamw bzero(param->info, sizeof (struct netdfs_enumex)); 7619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States param->status = ERROR_NOT_SUPPORTED; 7628d7e4166Sjose borrego return (NDR_DRC_OK); 763da6c28aaSamw } 764da6c28aaSamw 765da6c28aaSamw /* 7669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets the comment for the DFS link/root. 767da6c28aaSamw */ 7689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 7699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_setinfo_100(dfs_path_t *path, netdfs_info100_t *netinfo) 770da6c28aaSamw { 7719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_t info; 7729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status; 7739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char *cmnt = (char *)netinfo->comment; 7749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 7759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&info, sizeof (dfs_info_t)); 7769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (cmnt != NULL) 7779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(info.i_comment, cmnt, sizeof (info.i_comment)); 7789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 7799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (path->p_type == DFS_OBJECT_LINK) 7809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_setinfo(path->p_fspath, &info, 100); 7819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else 7829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_root_setinfo(path->p_fspath, &info, 100); 7839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 7849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (status); 7859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 7869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 7879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 7889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets the state for the DFS root/link or its target. 7899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 7909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 7919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_setinfo_101(dfs_path_t *path, netdfs_info101_t *netinfo, 7929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *t_server, const char *t_share) 7939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 7949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_t info; 7959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_target_t target; 7969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status; 7979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 7989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&info, sizeof (dfs_info_t)); 7999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&target, sizeof (dfs_target_t)); 8009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (t_server == NULL && t_share == NULL) { 8029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info.i_state = netinfo->state; 8039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } else { 8049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States target.t_state = netinfo->state; 8059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(target.t_server, t_server, 8069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States sizeof (target.t_server)); 8079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(target.t_share, t_share, 8089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States sizeof (target.t_share)); 8099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info.i_targets = ⌖ 8109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 8119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (path->p_type == DFS_OBJECT_LINK) 8139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_setinfo(path->p_fspath, &info, 101); 8149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else 8159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_root_setinfo(path->p_fspath, &info, 101); 8169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (status); 8189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 8199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 8219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets the timeout value of the DFS link/root. 8229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 8239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 8249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_setinfo_102(dfs_path_t *path, netdfs_info102_t *netinfo) 8259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 8269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_t info; 8279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status; 8289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&info, sizeof (dfs_info_t)); 8309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info.i_timeout = netinfo->timeout; 8319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (path->p_type == DFS_OBJECT_LINK) 8339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_setinfo(path->p_fspath, &info, 102); 8349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else 8359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_root_setinfo(path->p_fspath, &info, 102); 8369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (status); 8389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 8399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 8419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets the property flags for the root or link. 8429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 8439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 8449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_setinfo_103(dfs_path_t *path, netdfs_info103_t *netinfo) 8459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 8469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_t info; 8479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status; 8489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&info, sizeof (dfs_info_t)); 8509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info.i_propflags = 8519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netinfo->property_flags & netinfo->property_flag_mask; 8529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (path->p_type == DFS_OBJECT_LINK) 8549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_setinfo(path->p_fspath, &info, 103); 8559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else 8569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_root_setinfo(path->p_fspath, &info, 103); 8579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (status); 8599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 8609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 8629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets the target priority rank and class for the root target or link target 8639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 8649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 8659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_setinfo_104(dfs_path_t *path, netdfs_info104_t *netinfo, 8669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States const char *t_server, const char *t_share) 8679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 8689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_t info; 8699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_target_t target; 8709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status; 8719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((t_server == NULL) || (t_share == NULL)) 8739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_INVALID_PARAMETER); 8749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 875*cb174861Sjoyce mcintosh if (netinfo->priority_class > DfsGlobalLowPriorityClass) 876*cb174861Sjoyce mcintosh return (ERROR_INVALID_PARAMETER); 877*cb174861Sjoyce mcintosh 878*cb174861Sjoyce mcintosh if (netinfo->priority_rank > DFS_PRIORITY_RANK_MAX) 879*cb174861Sjoyce mcintosh return (ERROR_INVALID_PARAMETER); 880*cb174861Sjoyce mcintosh 8819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&info, sizeof (dfs_info_t)); 8829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&target, sizeof (dfs_target_t)); 8839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States target.t_priority.p_class = netinfo->priority_class; 8859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States target.t_priority.p_rank = netinfo->priority_rank; 8869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(target.t_server, t_server, sizeof (target.t_server)); 8879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(target.t_share, t_share, sizeof (target.t_share)); 8889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info.i_targets = ⌖ 8899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (path->p_type == DFS_OBJECT_LINK) 8919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_setinfo(path->p_fspath, &info, 104); 8929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else 8939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_root_setinfo(path->p_fspath, &info, 104); 8949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (status); 8969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 8979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 8989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 8999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets the comment, state, time-out information, and property flags for the 9009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * namespace root or link specified in DfsInfo. Does not apply to a root target 9019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * or link target. 9029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 9039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 9049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_setinfo_105(dfs_path_t *path, netdfs_info105_t *netinfo) 9059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 9069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_t info; 907*cb174861Sjoyce mcintosh uint32_t status, flavor; 9089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char *cmnt = (char *)netinfo->comment; 9099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bzero(&info, sizeof (dfs_info_t)); 9119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 912*cb174861Sjoyce mcintosh flavor = dfs_namespace_getflavor(path->p_unc.unc_share); 913*cb174861Sjoyce mcintosh if (flavor == 0) 914*cb174861Sjoyce mcintosh return (ERROR_INTERNAL_ERROR); 915*cb174861Sjoyce mcintosh info.i_flavor = flavor; 916*cb174861Sjoyce mcintosh 9179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (cmnt != NULL) 9189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(info.i_comment, cmnt, sizeof (info.i_comment)); 9199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info.i_state = netinfo->state; 9209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info.i_timeout = netinfo->timeout; 921*cb174861Sjoyce mcintosh info.i_propflag_mask = netinfo->property_flag_mask; 9229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info.i_propflags = 9239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netinfo->property_flags & netinfo->property_flag_mask; 9249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (path->p_type == DFS_OBJECT_LINK) 9269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_link_setinfo(path->p_fspath, &info, 105); 9279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States else 9289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_root_setinfo(path->p_fspath, &info, 105); 9299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (status); 9319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 9329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 9349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * DFS_STORAGE_INFO: target information 9359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 9369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 9379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_storage(netdfs_storage_info_t **sinfo, dfs_info_t *info, 9389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ndr_xa_t *mxa, uint32_t *size) 9399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 9409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_storage_info_t *storage; 9419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_target_t *target; 9429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States int i; 9439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *sinfo = NULL; 9459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (info->i_ntargets == 0) 9469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 9479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *sinfo = NDR_NEWN(mxa, netdfs_storage_info_t, info->i_ntargets); 9499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (*sinfo == NULL) 9509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 9519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 9539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size += info->i_ntargets * sizeof (netdfs_storage_info_t); 9549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States target = info->i_targets; 9569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage = *sinfo; 9579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States for (i = 0; i < info->i_ntargets; i++, target++, storage++) { 9589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->state = target->t_state; 9599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->server = NDR_STRDUP(mxa, target->t_server); 9609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->share = NDR_STRDUP(mxa, target->t_share); 9619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (storage->server == NULL || storage->share == NULL) 9639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 9649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 9669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size += smb_wcequiv_strlen(target->t_server) + 9679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(target->t_share); 9689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 9699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 9719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 9729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 9749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * DFS_STORAGE_INFO_1: target information 9759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 9769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 9779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_storage1(netdfs_storage_info1_t **sinfo, dfs_info_t *info, 9789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States ndr_xa_t *mxa, uint32_t *size) 9799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 9809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_storage_info1_t *storage; 9819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_target_t *target; 9829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States int i; 9839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *sinfo = NULL; 9859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (info->i_ntargets == 0) 9869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 9879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *sinfo = NDR_NEWN(mxa, netdfs_storage_info1_t, info->i_ntargets); 9899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (*sinfo == NULL) 9909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 9919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 9939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size += info->i_ntargets * sizeof (netdfs_storage_info1_t); 9949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 9959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States target = info->i_targets; 9969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage = *sinfo; 9979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States for (i = 0; i < info->i_ntargets; i++, target++, storage++) { 9989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->state = target->t_state; 9999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->server = NDR_STRDUP(mxa, target->t_server); 10009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->share = NDR_STRDUP(mxa, target->t_share); 10019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->p_class = target->t_priority.p_class; 10029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->p_rank = target->t_priority.p_rank; 10039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States storage->p_reserved = 0; 10049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (storage->server == NULL || storage->share == NULL) 10069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 10079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 10099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size += smb_wcequiv_strlen(target->t_server) + 10109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(target->t_share); 10119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 10129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 10149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 10159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 10179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets a DFS_INFO_1 for get/enum response 10189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 10199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 10209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_1(netdfs_info1_t *info1, dfs_info_t *info, ndr_xa_t *mxa, 10219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *size) 10229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 10239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info1->entry_path = NDR_STRDUP(mxa, info->i_uncpath); 10249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (info1->entry_path == NULL) 10259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 10269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 10289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size = sizeof (netdfs_info1_t) + 10299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_uncpath); 10309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 10329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 10339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 10359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets a DFS_INFO_2 for get/enum response 10369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 10379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 10389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_2(netdfs_info2_t *info2, dfs_info_t *info, ndr_xa_t *mxa, 10399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *size) 10409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 10419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *entry_path; 10429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *comment; 10439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entry_path = NDR_STRDUP(mxa, info->i_uncpath); 10459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States comment = NDR_STRDUP(mxa, info->i_comment); 10469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (entry_path == NULL || comment == NULL) 10489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 10499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info2->entry_path = entry_path; 10519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info2->comment = comment; 10529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info2->state = info->i_state; 10539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info2->n_store = info->i_ntargets; 10549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 10569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size = sizeof (netdfs_info2_t) + 10579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_uncpath) + 10589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_comment); 10599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 10619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 10629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 10649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets a DFS_INFO_3 for get/enum response 10659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 10669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 10679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_3(netdfs_info3_t *info3, dfs_info_t *info, ndr_xa_t *mxa, 10689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *size) 10699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 10709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *entry_path; 10719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *comment; 10729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entry_path = NDR_STRDUP(mxa, info->i_uncpath); 10749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States comment = NDR_STRDUP(mxa, info->i_comment); 10759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (entry_path == NULL || comment == NULL) 10779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 10789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info3->entry_path = entry_path; 10809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info3->comment = comment; 10819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info3->state = info->i_state; 10829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info3->n_store = info->i_ntargets; 10839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 10859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size = sizeof (netdfs_info3_t) + 10869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_uncpath) + 10879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_comment); 10889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (netdfs_info_storage(&info3->si, info, mxa, size)); 10909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 10919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 10929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 10939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets a DFS_INFO_4 for get/enum response 10949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 10959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 10969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_4(netdfs_info4_t *info4, dfs_info_t *info, ndr_xa_t *mxa, 10979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *size) 10989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 10999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *entry_path; 11009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *comment; 11019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entry_path = NDR_STRDUP(mxa, info->i_uncpath); 11039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States comment = NDR_STRDUP(mxa, info->i_comment); 11049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (entry_path == NULL || comment == NULL) 11069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 11079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!netdfs_guid_fromstr(info->i_guid, &info4->guid)) 11099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_INVALID_DATA); 11109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info4->entry_path = entry_path; 11129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info4->comment = comment; 11139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info4->state = info->i_state; 11149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info4->timeout = info->i_timeout; 11159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info4->n_store = info->i_ntargets; 11169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 11189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size = sizeof (netdfs_info4_t) + 11199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_uncpath) + 11209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_comment); 11219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (netdfs_info_storage(&info4->si, info, mxa, size)); 11239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 11249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 11269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets a DFS_INFO_5 for get/enum response 11279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 11289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 11299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_5(netdfs_info5_t *info5, dfs_info_t *info, ndr_xa_t *mxa, 11309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *size) 11319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 11329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *entry_path; 11339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *comment; 11349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entry_path = NDR_STRDUP(mxa, info->i_uncpath); 11369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States comment = NDR_STRDUP(mxa, info->i_comment); 11379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (entry_path == NULL || comment == NULL) 11399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 11409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!netdfs_guid_fromstr(info->i_guid, &info5->guid)) 11429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_INVALID_DATA); 11439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info5->entry_path = entry_path; 11459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info5->comment = comment; 11469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info5->state = info->i_state; 11479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info5->timeout = info->i_timeout; 11489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info5->flags = info->i_propflags; 11499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info5->metadata_sz = 0; 11509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info5->n_store = info->i_ntargets; 11519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 11539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size = sizeof (netdfs_info5_t) + 11549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_uncpath) + 11559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_comment); 11569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 11589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 11599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 11619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets a DFS_INFO_6 for get/enum response 11629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 11639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 11649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_6(netdfs_info6_t *info6, dfs_info_t *info, ndr_xa_t *mxa, 11659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *size) 11669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 11679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *entry_path; 11689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States void *comment; 11699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States entry_path = NDR_STRDUP(mxa, info->i_uncpath); 11719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States comment = NDR_STRDUP(mxa, info->i_comment); 11729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (entry_path == NULL || comment == NULL) 11749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 11759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (!netdfs_guid_fromstr(info->i_guid, &info6->guid)) 11779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_INVALID_DATA); 11789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info6->entry_path = entry_path; 11809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info6->comment = comment; 11819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info6->state = info->i_state; 11829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info6->timeout = info->i_timeout; 11839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info6->flags = info->i_propflags; 11849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info6->metadata_sz = 0; 11859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info6->n_store = info->i_ntargets; 11869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 11889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size = sizeof (netdfs_info6_t) + 11899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_uncpath) + 11909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_comment); 11919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (netdfs_info_storage1(&info6->si, info, mxa, size)); 11939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 11949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 11959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 11969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets a DFS_INFO_100 for Get response 11979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 11989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 11999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_100(netdfs_info100_t *info100, dfs_info_t *info, ndr_xa_t *mxa, 12009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *size) 12019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 12029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info100->comment = NDR_STRDUP(mxa, info->i_comment); 12039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (info100->comment == NULL) 12049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 12059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 12079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size = sizeof (netdfs_info100_t) + 12089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_comment); 12099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 12119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 12129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 12149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Sets a DFS_INFO_300 for Enum response 12159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 12169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 12179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info_300(netdfs_info300_t *info300, dfs_info_t *info, ndr_xa_t *mxa, 12189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t *size) 12199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 12209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info300->dfsname = NDR_STRDUP(mxa, info->i_uncpath); 12219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (info300->dfsname == NULL) 12229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_NOT_ENOUGH_MEMORY); 12239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info300->flavor = DFS_VOLUME_FLAVOR_STANDALONE; 12259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (size != NULL) 12269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States *size = sizeof (netdfs_info300_t) + 12279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_wcequiv_strlen(info->i_uncpath); 12289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 12309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 12319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 12339fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Common enumeration function 12349fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 12359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static uint32_t 12369fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_enum_common(netdfs_enumhandle_t *de, ndr_xa_t *mxa) 12379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 12389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info1_t *info1 = de->de_entries; 12399fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info2_t *info2 = de->de_entries; 12409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info3_t *info3 = de->de_entries; 12419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info4_t *info4 = de->de_entries; 12429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info5_t *info5 = de->de_entries; 12439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info6_t *info6 = de->de_entries; 12449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_info300_t *info300 = de->de_entries; 12459fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_t dfsinfo; 12469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States smb_cache_cursor_t cursor; 12479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_nscnode_t nscnode; 12489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status; 12499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t itemsz; 12509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_cache_iterinit(&cursor); 12529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de->de_nitems = 0; 12549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States while (dfs_cache_iterate(&cursor, &nscnode)) { 12559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de->de_nskip > 0) { 12569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de->de_nskip--; 12579fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States continue; 12589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 12599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de->de_nitems == de->de_nmax) 12619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 12629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12639fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_cache_getinfo(&nscnode, &dfsinfo, de->de_level); 12649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) 12659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States continue; 12669fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 12679fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States switch (de->de_level) { 12689fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 1: 12699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_1(info1, &dfsinfo, mxa, &itemsz); 12709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info1++; 12719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 12729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 2: 12739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_2(info2, &dfsinfo, mxa, &itemsz); 12749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info2++; 12759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 12769fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 3: 12779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_3(info3, &dfsinfo, mxa, &itemsz); 12789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info3++; 12799fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 12809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 4: 12819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_4(info4, &dfsinfo, mxa, &itemsz); 12829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info4++; 12839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 12849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 5: 12859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_5(info5, &dfsinfo, mxa, &itemsz); 12869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info5++; 12879fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 12889fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 6: 12899fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_6(info6, &dfsinfo, mxa, &itemsz); 12909fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info6++; 12919fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 12929fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States case 300: 12939fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = netdfs_info_300(info300, &dfsinfo, mxa, 12949fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States &itemsz); 12959fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States info300++; 12969fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 12979fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States default: 12989fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = ERROR_INVALID_LEVEL; 12999fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 13009fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13019fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States dfs_info_free(&dfsinfo); 13029fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13039fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) 13049fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (status); 13059fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13069fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (de->de_nmax == 1) { 13079fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de->de_nitems = 1; 13089fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 13099fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 13109fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13119fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (itemsz > de->de_bavail) 13129fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States break; 13139fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13149fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de->de_bavail -= itemsz; 13159fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de->de_nitems++; 13169fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 13179fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13189fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States de->de_resume += de->de_nitems; 13199fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (ERROR_SUCCESS); 13209fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 13219fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13229fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 13239fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Creates intermediate directories of a link from the root share path. 13249fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * 13259fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * TODO: directories should be created by smbsrv to get Windows compatible 13269fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * ACL inheritance. 13279fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 13289fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static void 13299fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_path_create(const char *path) 13309fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 13319fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char dirpath[DFS_PATH_MAX]; 13329fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States mode_t mode; 1333da6c28aaSamw char *p; 1334da6c28aaSamw 13359fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(dirpath, path, DFS_PATH_MAX); 1336da6c28aaSamw 13379fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* drop the link itself from the path */ 13389fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((p = strrchr(dirpath, '/')) != NULL) { 1339da6c28aaSamw *p = '\0'; 13409fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States mode = umask(0); 13419fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) mkdirp(dirpath, 0777); 13429fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) umask(mode); 13439fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 13449fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1345da6c28aaSamw 13469fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 13479fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Removes empty directories 13489fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 13499fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static void 13509fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_path_remove(smb_unc_t *unc) 13519fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 13529fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char rootdir[DFS_PATH_MAX]; 13539fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char relpath[DFS_PATH_MAX]; 13549fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char dir[DFS_PATH_MAX]; 13559fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uint32_t status; 13569fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States char *p; 1357da6c28aaSamw 13589fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States status = dfs_namespace_path(unc->unc_share, rootdir, DFS_PATH_MAX); 13599fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((status == ERROR_SUCCESS) && (chdir(rootdir) == 0)) { 13609fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) strlcpy(relpath, unc->unc_path, DFS_PATH_MAX); 13619fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* drop the link itself from the path */ 13629fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if ((p = strrchr(relpath, '/')) != NULL) { 1363da6c28aaSamw *p = '\0'; 13649fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States (void) rmdirp(relpath, dir); 13659fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States } 1366da6c28aaSamw } 1367da6c28aaSamw } 1368da6c28aaSamw 13699fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States /* 13709fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States * Converts the guid string into binary format in network byte order. 13719fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States */ 13729fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States static boolean_t 13739fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States netdfs_guid_fromstr(char *guid_str, netdfs_uuid_t *guid) 13749fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States { 13759fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States uuid_t uuid; 1376da6c28aaSamw 13779fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States if (uuid_parse(guid_str, uuid) != 0) 13789fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (B_FALSE); 1379da6c28aaSamw 13809fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States bcopy(&uuid, guid, sizeof (uuid_t)); 13819fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13829fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States guid->data1 = htonl(guid->data1); 13839fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States guid->data2 = htons(guid->data2); 13849fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States guid->data3 = htons(guid->data3); 13859fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States 13869fb67ea3Safshin salek ardakani - Sun Microsystems - Irvine United States return (B_TRUE); 1387da6c28aaSamw } 1388