Remove my changes to pagefile creation because they cause a hang for some people.
[reactos.git] / posix / apps / bootpsx / bootpsx.c
1 /* $Id$
2 *
3 * PROJECT: ReactOS Operating System / POSIX Environment Subsystem
4 *
5 * --------------------------------------------------------------------
6 *
7 * This software is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this software; see the file COPYING. If not, write
19 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
20 * MA 02139, USA.
21 *
22 * --------------------------------------------------------------------
23 */
24 #include <windows.h>
25 #include <stdio.h>
26 #include <stdlib.h>
27
28 #define NTOS_MODE_USER
29 #include <ntos.h>
30 #include <sm/helper.h>
31
32 #define RETRY_COUNT 3
33
34 /**********************************************************************
35 * PsxCheckSubSystem/1
36 */
37 NTSTATUS STDCALL
38 PsxCheckSubSystem (LPCSTR argv0)
39 {
40 NTSTATUS Status = STATUS_SUCCESS;
41 UNICODE_STRING DirectoryName = {0, 0, NULL};
42 OBJECT_ATTRIBUTES DirectoryAttributes = {0};
43 HANDLE hDir = (HANDLE) 0;
44
45 RtlInitUnicodeString (& DirectoryName, L"\\POSIX");
46 InitializeObjectAttributes (& DirectoryAttributes,
47 & DirectoryName,
48 0,0,0);
49 Status = NtOpenDirectoryObject (& hDir,
50 DIRECTORY_TRAVERSE,
51 & DirectoryAttributes);
52 if(NT_SUCCESS(Status))
53 {
54 NtClose (hDir);
55 }
56
57 return Status;
58 }
59
60 /**********************************************************************
61 * PsxBootstrap/1
62 */
63 NTSTATUS STDCALL
64 PsxBootstrap (LPCSTR argv0)
65 {
66 NTSTATUS Status = STATUS_SUCCESS;
67 UNICODE_STRING Program = {0, 0, NULL};
68 HANDLE SmApiPort = (HANDLE) 0;
69
70
71 printf("Connecting to the SM: ");
72 Status = SmConnectApiPort (NULL,
73 (HANDLE) 0,
74 IMAGE_SUBSYSTEM_UNKNOWN,
75 & SmApiPort);
76 if(!NT_SUCCESS(Status))
77 {
78 fprintf(stderr,"\n%s: SmConnectApiPort failed with 0x%08lx\n",
79 argv0, Status);
80 return Status;
81 }
82 RtlInitUnicodeString (& Program, L"POSIX");
83 Status = SmExecuteProgram (SmApiPort, & Program);
84 if(STATUS_SUCCESS != Status)
85 {
86 fprintf(stderr, "%s: SmExecuteProgram = %08lx\n", argv0, Status);
87 }
88 NtClose (SmApiPort);
89 return Status;
90 }
91
92 /**********************************************************************
93 *
94 * ENTRY POINT PUBLIC
95 *
96 *********************************************************************/
97 int main (int argc, char * argv [])
98 {
99 NTSTATUS Status = STATUS_SUCCESS;
100 INT RetryCount = RETRY_COUNT;
101
102 while(RetryCount > 0)
103 {
104 Status = PsxCheckSubSystem (argv[0]);
105 if(STATUS_SUCCESS == Status)
106 {
107 if (RETRY_COUNT == RetryCount)
108 {
109 fprintf(stderr,"POSIX already booted.\n");
110 }else{
111 fprintf(stderr,"POSIX booted.\n");
112 }
113 break;
114 }else{
115 Status = PsxBootstrap (argv[0]);
116 }
117 -- RetryCount;
118 }
119 return NT_SUCCESS(Status) ? EXIT_SUCCESS : EXIT_FAILURE;
120 }
121 /* EOF */