ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Urlader/urlader.c
(Generate patch)

Comparing Urlader/urlader.c (file contents):
Revision 1.3 by root, Thu Dec 29 10:39:34 2011 UTC vs.
Revision 1.4 by root, Fri Dec 30 05:27:32 2011 UTC

33 #define u_open(path) CreateFile (path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL) 33 #define u_open(path) CreateFile (path, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL)
34 #define u_creat(path,exec) CreateFile (path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL) 34 #define u_creat(path,exec) CreateFile (path, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL)
35 #define u_close(handle) CloseHandle (handle) 35 #define u_close(handle) CloseHandle (handle)
36 #define u_append(path,add) PathAppend (path, add) 36 #define u_append(path,add) PathAppend (path, add)
37 #define u_write(handle,data,len) (WriteFile (handle, data, len, &dword, 0) ? dword : -1) 37 #define u_write(handle,data,len) (WriteFile (handle, data, len, &dword, 0) ? dword : -1)
38 #define u_sync() // use transacted I/O? 38
39 #define u_fsync(handle) FlushFileBuffers (handle)
40 #define u_sync()
39 41
40#else 42#else
41 43
42 #include <sys/mman.h> 44 #include <sys/mman.h>
43 #include <sys/types.h> 45 #include <sys/types.h>
57 #define u_open(path) open (path, O_RDONLY) + 1 59 #define u_open(path) open (path, O_RDONLY) + 1
58 #define u_creat(path,exec) open (path, O_WRONLY | O_CREAT | O_TRUNC, (exec) ? 0777 : 0666) + 1 60 #define u_creat(path,exec) open (path, O_WRONLY | O_CREAT | O_TRUNC, (exec) ? 0777 : 0666) + 1
59 #define u_close(handle) close (handle - 1) 61 #define u_close(handle) close (handle - 1)
60 #define u_append(path,add) strcat (strcat (path, "/"), add) 62 #define u_append(path,add) strcat (strcat (path, "/"), add)
61 #define u_write(handle,data,len) write ((handle) - 1, data, len) 63 #define u_write(handle,data,len) write ((handle) - 1, data, len)
64
65 // on a mostly idle system, a sync at the end is certainly faster, hope for the best
66 #define u_fsync(handle)
62 #define u_sync() sync () 67 #define u_sync() sync ()
63 68
64#endif 69#endif
65 70
66#define u_16(ptr) (((ptr)[0] << 8) | (ptr)[1]) 71#define u_16(ptr) (((ptr)[0] << 8) | (ptr)[1])
145 150
146enum 151enum
147{ 152{
148 T_NULL, // 5 153 T_NULL, // 5
149 T_META, // 1 : exe_id, exe_ver 154 T_META, // 1 : exe_id, exe_ver
150 T_ARG, // 2 : arg
151 T_ENV, // 3 : name, value 155 T_ENV, // 2 : name, value
156 T_ARG, // 3 : arg
152 T_DIR, // 4+: path 157 T_DIR, // 4+: path
153 T_FILE, // 4+: path, data 158 T_FILE, // 4+: path, data
154 T_NUM 159 T_NUM
155}; 160};
156 161
304 fatal ("unable to locate override metadata"); 309 fatal ("unable to locate override metadata");
305 310
306 strcpy (exe_ver, PACK_DATA); 311 strcpy (exe_ver, PACK_DATA);
307 pack_next (); 312 pack_next ();
308 313
314 for (;;)
315 {
316 if (pack_cur->type == T_ENV)
317 u_setenv (PACK_NAME, PACK_DATA);
309 while (pack_cur->type == T_ARG) 318 else if (pack_cur->type == T_ARG)
310 {
311 exe_argv [exe_argc++] = strdup (PACK_NAME); 319 exe_argv [exe_argc++] = strdup (PACK_NAME);
320 else
321 break;
322
312 pack_next (); 323 pack_next ();
313 } 324 }
314 325
315 while (pack_cur->type == T_ENV) 326done_env_arg:
316 {
317 u_setenv (PACK_NAME, PACK_DATA);
318 pack_next ();
319 }
320
321 strcpy (execdir, exe_dir); 327 strcpy (execdir, exe_dir);
322 u_append (execdir, "i-"); 328 u_append (execdir, "i-");
323 strcat (execdir, exe_ver); 329 strcat (execdir, exe_ver);
324 330
325 if (access (execdir, F_OK)) 331 if (access (execdir, F_OK))
357 fatal ("unable to unpack file from packfile - disk full?"); 363 fatal ("unable to unpack file from packfile - disk full?");
358 364
359 if (u_write (h, data, len) != len) 365 if (u_write (h, data, len) != len)
360 fatal ("unable to unpack file from packfile - disk full?"); 366 fatal ("unable to unpack file from packfile - disk full?");
361 367
368 u_fsync (h);
362 u_close (h); 369 u_close (h);
363 } 370 }
364 break; 371 break;
365 372
366 case T_NULL: 373 case T_NULL:

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines