Revision 5fafdf24 osdep.c

b/osdep.c
1 1
/*
2 2
 * QEMU low level functions
3
 * 
3
 *
4 4
 * Copyright (c) 2003 Fabrice Bellard
5
 * 
5
 *
6 6
 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 7
 * of this software and associated documentation files (the "Software"), to deal
8 8
 * in the Software without restriction, including without limitation the rights
......
114 114
            free_space = (int64_t)stfs.f_bavail * stfs.f_bsize;
115 115
            if ((ram_size + 8192 * 1024) >= free_space) {
116 116
                ram_mb = (ram_size / (1024 * 1024));
117
                fprintf(stderr, 
117
                fprintf(stderr,
118 118
                        "You do not have enough space in '%s' for the %d MB of QEMU virtual RAM.\n",
119 119
                        tmpdir, ram_mb);
120 120
                if (strcmp(tmpdir, "/dev/shm") == 0) {
......
123 123
                            "mount -t tmpfs -o size=%dm none /dev/shm\n",
124 124
                            ram_mb + 16);
125 125
                } else {
126
                    fprintf(stderr, 
126
                    fprintf(stderr,
127 127
                            "Use the '-m' option of QEMU to diminish the amount of virtual RAM or use the\n"
128 128
                            "QEMU_TMPDIR environment variable to set another directory where the QEMU\n"
129 129
                            "temporary RAM file will be opened.\n");
......
132 132
                exit(1);
133 133
            }
134 134
        }
135
        snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX", 
135
        snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX",
136 136
                 tmpdir);
137 137
        phys_ram_fd = mkstemp(phys_ram_file);
138 138
        if (phys_ram_fd < 0) {
139
            fprintf(stderr, 
139
            fprintf(stderr,
140 140
                    "warning: could not create temporary file in '%s'.\n"
141 141
                    "Use QEMU_TMPDIR to select a directory in a tmpfs filesystem.\n"
142 142
                    "Using '/tmp' as fallback.\n",
143 143
                    tmpdir);
144
            snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX", 
144
            snprintf(phys_ram_file, sizeof(phys_ram_file), "%s/qemuXXXXXX",
145 145
                     "/tmp");
146 146
            phys_ram_fd = mkstemp(phys_ram_file);
147 147
            if (phys_ram_fd < 0) {
148
                fprintf(stderr, "Could not create temporary memory file '%s'\n", 
148
                fprintf(stderr, "Could not create temporary memory file '%s'\n",
149 149
                        phys_ram_file);
150 150
                exit(1);
151 151
            }
......
154 154
    }
155 155
    size = (size + 4095) & ~4095;
156 156
    ftruncate(phys_ram_fd, phys_ram_size + size);
157
    ptr = mmap(NULL, 
158
               size, 
159
               PROT_WRITE | PROT_READ, MAP_SHARED, 
157
    ptr = mmap(NULL,
158
               size,
159
               PROT_WRITE | PROT_READ, MAP_SHARED,
160 160
               phys_ram_fd, phys_ram_size);
161 161
    if (ptr == MAP_FAILED) {
162 162
        fprintf(stderr, "Could not map physical memory\n");
......
242 242
    BOOL ret;
243 243

  
244 244
    /* Open for writing with no sharing. */
245
    file = CreateFile(filename, GENERIC_WRITE, 0, NULL, 
245
    file = CreateFile(filename, GENERIC_WRITE, 0, NULL,
246 246
		      OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
247 247

  
248 248
    if (file == INVALID_HANDLE_VALUE)
......
257 257

  
258 258
    /* Write PID to file. */
259 259
    len = snprintf(buffer, sizeof(buffer), "%ld\n", (long)getpid());
260
    ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len, 
260
    ret = WriteFileEx(file, (LPCVOID)buffer, (DWORD)len,
261 261
		      &overlap, NULL);
262 262
    if (ret == 0)
263 263
      return -1;

Also available in: Unified diff