summaryrefslogtreecommitdiffstats
path: root/private/nw/ndsutils/setshare.c
blob: 92caf2ee8863666e289d7d27bb23bb7b7d084971 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/***

Copyright (c) 1996  Microsoft Corporation

Module Name:

    SetShare.c

Abstract:

    This is a command line test utility for setting the
    shareable bit on a file on a Netware server.

Author:

    Cory West       [corywest]  25-April-96

***/

#include "ndsapi32.h"

int
_cdecl main(
    int argc,
    char **argv
) {

    NTSTATUS Status;
    int ReturnCode = 0;
    IO_STATUS_BLOCK IoStatusBlock;
    HANDLE hFile;

    //
    // Check the command line arguments for a file.
    //

    if ( argc < 1 ) {
        printf( "Usage: setshare [path to file]\n" );
        return -1;
    }

    //
    // Open the file.
    //

    hFile = CreateFile( argv[1],       // file name
                        GENERIC_READ,  // read access
                        0,             // exclusive
                        NULL,          // no security specifications
                        OPEN_EXISTING, // do not create
                        0,             // no attributes that we care about
                        NULL );        // no template

    if ( hFile == INVALID_HANDLE_VALUE ) {
        printf( "Couldn't open the request file.  Error = %08lx\n", Status );
        return -1;
    }

    //
    // Tell the redirector to set the shareable bit.
    //

    Status = NtFsControlFile( hFile,
                              NULL,
                              NULL,
                              NULL,
                              &IoStatusBlock,
                              FSCTL_NWR_SET_SHAREBIT,
                              NULL,
                              0,
                              NULL,
                              0 );

    if ( !NT_SUCCESS( Status ) ) {
        printf( "A parameter was not correct.  This only works for a file\n" );
        printf( "on a Netware volume.  Status = %08lx\n", Status );
        ReturnCode = -1;
    }

    CloseHandle( hFile );

    //
    // The bit actually gets set when you close the file.
    //

    return ReturnCode;

}