~darkxst/ubuntu/raring/xorg-server/lp1073724

« back to all changes in this revision

Viewing changes to hw/xfree86/os-support/solaris/sun_init.c

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2010-06-07 14:50:49 UTC
  • mfrom: (0.9.4 upstream)
  • mto: This revision was merged to the branch mainline in revision 187.
  • Revision ID: james.westby@ubuntu.com-20100607145049-eys326hqtq5mjqxt
Tags: upstream-1.8.1.901
ImportĀ upstreamĀ versionĀ 1.8.1.901

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
# include <sys/kd.h>
34
34
#endif
35
35
 
 
36
/*
 
37
 * Applications see VT number as consecutive integers starting from 1.
 
38
 * VT number                    VT device
 
39
 * -------------------------------------------------------
 
40
 *     1             :          /dev/vt/0 (Alt + Ctrl + F1)
 
41
 *     2             :          /dev/vt/2 (Alt + Ctrl + F2)
 
42
 *     3             :          /dev/vt/3 (Alt + Ctrl + F3)
 
43
 *  ... ...
 
44
 */
 
45
#define CONSOLE_VTNO    1
 
46
#define SOL_CONSOLE_DEV "/dev/console"
 
47
 
36
48
static Bool KeepTty = FALSE;
37
49
static Bool Protect0 = FALSE;
 
50
static Bool UseConsole = FALSE;
38
51
#ifdef HAS_USL_VTS
39
52
static int VTnum = -1;
40
53
static int xf86StartVT = -1;
112
125
                vtEnabled = 0;
113
126
            }
114
127
        }
115
 
 
116
 
 
 
128
#endif /*  HAS_USL_VTS */
 
129
 
 
130
        if (UseConsole)
 
131
        {
 
132
            strlcpy(consoleDev, SOL_CONSOLE_DEV, sizeof(consoleDev));
 
133
 
 
134
#ifdef HAS_USL_VTS
 
135
            xf86Info.vtno = CONSOLE_VTNO;
 
136
 
 
137
            if (vtEnabled == 0)
 
138
            {
 
139
                xf86StartVT = 0;
 
140
            }
 
141
            else
 
142
            {
 
143
                if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
 
144
                    FatalError("xf86OpenConsole: Cannot determine current VT\n");
 
145
                xf86StartVT = vtinfo.v_active;
 
146
            }
 
147
#endif /*  HAS_USL_VTS */
 
148
            goto OPENCONSOLE;
 
149
        }
 
150
 
 
151
#ifdef HAS_USL_VTS
117
152
        if (vtEnabled == 0)
118
153
        {
119
154
            /* VT not enabled - kernel too old or Sparc platforms
123
158
            xf86StartVT = 0;
124
159
            xf86Info.vtno = 0;
125
160
            strlcpy(consoleDev, xf86SolarisFbDev, sizeof(consoleDev));
 
161
            goto OPENCONSOLE;
 
162
        }
 
163
 
 
164
        if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
 
165
            FatalError("xf86OpenConsole: Cannot determine current VT\n");
 
166
 
 
167
        xf86StartVT = vtinfo.v_active;
 
168
 
 
169
        if (VTnum != -1)
 
170
        {
 
171
            xf86Info.vtno = VTnum;
 
172
            from = X_CMDLINE;
126
173
        }
127
174
        else
128
175
        {
129
 
            if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
130
 
                FatalError("xf86OpenConsole: Cannot determine current VT\n");
131
 
 
132
 
            xf86StartVT = vtinfo.v_active;
133
 
 
134
 
            if (VTnum != -1)
135
 
            {
136
 
                xf86Info.vtno = VTnum;
137
 
                from = X_CMDLINE;
138
 
            }
139
 
            else
140
 
            {
141
 
                if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
142
 
                    (xf86Info.vtno == -1))
143
 
                {
144
 
                    FatalError("xf86OpenConsole: Cannot find a free VT\n");
145
 
                }
146
 
            }
147
 
 
148
 
            xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
149
 
            snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
 
176
            if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
 
177
                (xf86Info.vtno == -1))
 
178
            {
 
179
                FatalError("xf86OpenConsole: Cannot find a free VT\n");
 
180
            }
150
181
        }
151
182
 
 
183
        xf86Msg(from, "using VT number %d\n\n", xf86Info.vtno);
 
184
        snprintf(consoleDev, PATH_MAX, "/dev/vt/%d", xf86Info.vtno);
 
185
 
152
186
        if (fd != -1)
153
187
        {
154
188
            close(fd);
156
190
 
157
191
#endif /* HAS_USL_VTS */
158
192
 
 
193
OPENCONSOLE:
159
194
        if (!KeepTty)
160
195
            setpgrp();
161
196
 
163
198
            FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
164
199
                       consoleDev, strerror(errno));
165
200
 
166
 
#ifdef HAS_USL_VTS
167
 
 
168
 
        /* Change ownership of the vt */
 
201
        /* Change ownership of the vt or console */
169
202
        chown(consoleDev, getuid(), getgid());
170
203
 
 
204
#ifdef HAS_USL_VTS
171
205
        if (vtEnabled)
172
206
        {
173
207
            /*
179
213
            if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
180
214
                xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
181
215
 
 
216
#ifdef VT_SET_CONSUSER /* added in snv_139 */
 
217
            if (strcmp(display, "0") == 0)
 
218
                if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
 
219
                    xf86Msg(X_WARNING,
 
220
                        "xf86OpenConsole: VT_SET_CONSUSER failed\n");
 
221
#endif
 
222
 
182
223
            if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0)
183
224
                FatalError("xf86OpenConsole: VT_GETMODE failed\n");
184
225
 
220
261
            if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
221
262
                xf86Msg(X_WARNING, "xf86OpenConsole: VT_WAITACTIVE failed\n");
222
263
 
 
264
#ifdef VT_SET_CONSUSER /* added in snv_139 */
 
265
            if (strcmp(display, "0") == 0)
 
266
                if (ioctl(xf86Info.consoleFd, VT_SET_CONSUSER) != 0)
 
267
                    xf86Msg(X_WARNING,
 
268
                        "xf86OpenConsole: VT_SET_CONSUSER failed\n");
 
269
#endif
 
270
 
223
271
            /*
224
272
             * If the server doesn't have the VT when the reset occurs,
225
273
             * this is to make sure we don't continue until the activate
330
378
        return 1;
331
379
    }
332
380
 
 
381
    /*
 
382
     * Use /dev/console as the console device.
 
383
     */
 
384
    if (!strcmp(argv[i], "-C"))
 
385
    {
 
386
        UseConsole = TRUE;
 
387
        return 1;
 
388
    }
 
389
 
333
390
#ifdef HAS_USL_VTS
334
391
 
335
392
    if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
364
421
    ErrorF("-dev <fb>              Framebuffer device\n");
365
422
    ErrorF("-keeptty               Don't detach controlling tty\n");
366
423
    ErrorF("                       (for debugging only)\n");
 
424
    ErrorF("-C                     Use /dev/console as the console device\n");
367
425
}