~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/os0file.h

  • Committer: Monty Taylor
  • Date: 2008-09-15 17:24:04 UTC
  • Revision ID: monty@inaugust.com-20080915172404-ygh6hiyu0q7qpa9x
Removed strndup calls.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
 
44
44
#ifdef __WIN__
45
45
#define os_file_t       HANDLE
46
 
#define OS_FILE_FROM_FD(fd) (HANDLE) _get_osfhandle(fd)
47
46
#else
48
47
typedef int     os_file_t;
49
 
#define OS_FILE_FROM_FD(fd) fd
50
48
#endif
51
49
 
52
50
extern ulint    os_innodb_umask;
159
157
struct os_file_stat_struct{
160
158
        char            name[OS_FILE_MAX_PATH]; /* path to a file */
161
159
        os_file_type_t  type;                   /* file type */
162
 
        ib_int64_t      size;                   /* file size */
 
160
        ib_longlong     size;                   /* file size */
163
161
        time_t          ctime;                  /* creation time */
164
162
        time_t          mtime;                  /* modification time */
165
163
        time_t          atime;                  /* access time */
174
172
 
175
173
/***************************************************************************
176
174
Gets the operating system version. Currently works only on Windows. */
177
 
UNIV_INTERN
 
175
 
178
176
ulint
179
177
os_get_os_version(void);
180
178
/*===================*/
181
179
                  /* out: OS_WIN95, OS_WIN31, OS_WINNT, or OS_WIN2000 */
182
180
/********************************************************************
183
181
Creates the seek mutexes used in positioned reads and writes. */
184
 
UNIV_INTERN
 
182
 
185
183
void
186
184
os_io_init_simple(void);
187
185
/*===================*/
200
198
directory named by the dirname argument. The directory stream is positioned
201
199
at the first entry. In both Unix and Windows we automatically skip the '.'
202
200
and '..' items at the start of the directory listing. */
203
 
UNIV_INTERN
 
201
 
204
202
os_file_dir_t
205
203
os_file_opendir(
206
204
/*============*/
215
213
                                        a directory */
216
214
/***************************************************************************
217
215
Closes a directory stream. */
218
 
UNIV_INTERN
 
216
 
219
217
int
220
218
os_file_closedir(
221
219
/*=============*/
224
222
/***************************************************************************
225
223
This function returns information of the next file in the directory. We jump
226
224
over the '.' and '..' entries in the directory. */
227
 
UNIV_INTERN
 
225
 
228
226
int
229
227
os_file_readdir_next_file(
230
228
/*======================*/
238
236
gets default permissions. On Unix, the permissions are (0770 & ~umask). If the
239
237
directory exists already, nothing is done and the call succeeds, unless the
240
238
fail_if_exists arguments is true. */
241
 
UNIV_INTERN
 
239
 
242
240
ibool
243
241
os_file_create_directory(
244
242
/*=====================*/
250
248
                                        is treated as an error. */
251
249
/********************************************************************
252
250
A simple function to open or create a file. */
253
 
UNIV_INTERN
 
251
 
254
252
os_file_t
255
253
os_file_create_simple(
256
254
/*==================*/
271
269
        ibool*          success);/* out: TRUE if succeed, FALSE if error */
272
270
/********************************************************************
273
271
A simple function to open or create a file. */
274
 
UNIV_INTERN
 
272
 
275
273
os_file_t
276
274
os_file_create_simple_no_error_handling(
277
275
/*====================================*/
290
288
                                used by a backup program reading the file */
291
289
        ibool*          success);/* out: TRUE if succeed, FALSE if error */
292
290
/********************************************************************
293
 
Tries to disable OS caching on an opened file descriptor. */
294
 
UNIV_INTERN
295
 
void
296
 
os_file_set_nocache(
297
 
/*================*/
298
 
        int             fd,             /* in: file descriptor to alter */
299
 
        const char*     file_name,      /* in: file name, used in the
300
 
                                        diagnostic message */
301
 
        const char*     operation_name);/* in: "open" or "create"; used in the
302
 
                                        diagnostic message */
303
 
/********************************************************************
304
291
Opens an existing file or creates a new. */
305
 
UNIV_INTERN
 
292
 
306
293
os_file_t
307
294
os_file_create(
308
295
/*===========*/
330
317
        ibool*          success);/* out: TRUE if succeed, FALSE if error */
331
318
/***************************************************************************
332
319
Deletes a file. The file has to be closed before calling this. */
333
 
UNIV_INTERN
 
320
 
334
321
ibool
335
322
os_file_delete(
336
323
/*===========*/
339
326
 
340
327
/***************************************************************************
341
328
Deletes a file if it exists. The file has to be closed before calling this. */
342
 
UNIV_INTERN
 
329
 
343
330
ibool
344
331
os_file_delete_if_exists(
345
332
/*=====================*/
348
335
/***************************************************************************
349
336
Renames a file (can also move it to another directory). It is safest that the
350
337
file is closed before calling this function. */
351
 
UNIV_INTERN
 
338
 
352
339
ibool
353
340
os_file_rename(
354
341
/*===========*/
359
346
/***************************************************************************
360
347
Closes a file handle. In case of error, error number can be retrieved with
361
348
os_file_get_last_error. */
362
 
UNIV_INTERN
 
349
 
363
350
ibool
364
351
os_file_close(
365
352
/*==========*/
367
354
        os_file_t       file);  /* in, own: handle to a file */
368
355
/***************************************************************************
369
356
Closes a file handle. */
370
 
UNIV_INTERN
 
357
 
371
358
ibool
372
359
os_file_close_no_error_handling(
373
360
/*============================*/
375
362
        os_file_t       file);  /* in, own: handle to a file */
376
363
/***************************************************************************
377
364
Gets a file size. */
378
 
UNIV_INTERN
 
365
 
379
366
ibool
380
367
os_file_get_size(
381
368
/*=============*/
385
372
                                size */
386
373
        ulint*          size_high);/* out: most significant 32 bits of size */
387
374
/***************************************************************************
388
 
Gets file size as a 64-bit integer ib_int64_t. */
389
 
UNIV_INTERN
390
 
ib_int64_t
 
375
Gets file size as a 64-bit integer ib_longlong. */
 
376
 
 
377
ib_longlong
391
378
os_file_get_size_as_iblonglong(
392
379
/*===========================*/
393
380
                                /* out: size in bytes, -1 if error */
394
381
        os_file_t       file);  /* in: handle to a file */
395
382
/***************************************************************************
396
383
Write the specified number of zeros to a newly created file. */
397
 
UNIV_INTERN
 
384
 
398
385
ibool
399
386
os_file_set_size(
400
387
/*=============*/
407
394
        ulint           size_high);/* in: most significant 32 bits of size */
408
395
/***************************************************************************
409
396
Truncates a file at its current position. */
410
 
UNIV_INTERN
 
397
 
411
398
ibool
412
399
os_file_set_eof(
413
400
/*============*/
415
402
        FILE*           file);  /* in: file to be truncated */
416
403
/***************************************************************************
417
404
Flushes the write buffers of a given file to the disk. */
418
 
UNIV_INTERN
 
405
 
419
406
ibool
420
407
os_file_flush(
421
408
/*==========*/
426
413
The number should be retrieved before any other OS calls (because they may
427
414
overwrite the error number). If the number is not known to this program,
428
415
the OS error number + 100 is returned. */
429
 
UNIV_INTERN
 
416
 
430
417
ulint
431
418
os_file_get_last_error(
432
419
/*===================*/
436
423
                                        printed of all errors */
437
424
/***********************************************************************
438
425
Requests a synchronous read operation. */
439
 
UNIV_INTERN
 
426
 
440
427
ibool
441
428
os_file_read(
442
429
/*=========*/
453
440
Rewind file to its start, read at most size - 1 bytes from it to str, and
454
441
NUL-terminate str. All errors are silently ignored. This function is
455
442
mostly meant to be used with temporary files. */
456
 
UNIV_INTERN
 
443
 
457
444
void
458
445
os_file_read_string(
459
446
/*================*/
463
450
/***********************************************************************
464
451
Requests a synchronous positioned read operation. This function does not do
465
452
any error handling. In case of error it returns FALSE. */
466
 
UNIV_INTERN
 
453
 
467
454
ibool
468
455
os_file_read_no_error_handling(
469
456
/*===========================*/
479
466
 
480
467
/***********************************************************************
481
468
Requests a synchronous write operation. */
482
 
UNIV_INTERN
 
469
 
483
470
ibool
484
471
os_file_write(
485
472
/*==========*/
496
483
        ulint           n);     /* in: number of bytes to write */
497
484
/***********************************************************************
498
485
Check the existence and type of the given file. */
499
 
UNIV_INTERN
 
486
 
500
487
ibool
501
488
os_file_status(
502
489
/*===========*/
531
518
       "."            "."            "."
532
519
       ".."           "."            ".."
533
520
*/
534
 
UNIV_INTERN
 
521
 
535
522
char*
536
523
os_file_dirname(
537
524
/*============*/
540
527
        const char*     path);  /* in: pathname */
541
528
/********************************************************************
542
529
Creates all missing subdirectories along the given path. */
543
 
UNIV_INTERN
 
530
 
544
531
ibool
545
532
os_file_create_subdirs_if_needed(
546
533
/*=============================*/
555
542
in the three first aio arrays is the parameter n_segments given to the
556
543
function. The caller must create an i/o handler thread for each segment in
557
544
the four first arrays, but not for the sync aio array. */
558
 
UNIV_INTERN
 
545
 
559
546
void
560
547
os_aio_init(
561
548
/*========*/
566
553
        ulint   n_slots_sync);  /* in: number of slots in the sync aio array */
567
554
/***********************************************************************
568
555
Requests an asynchronous i/o operation. */
569
 
UNIV_INTERN
 
556
 
570
557
ibool
571
558
os_aio(
572
559
/*===*/
604
591
/****************************************************************************
605
592
Wakes up all async i/o threads so that they know to exit themselves in
606
593
shutdown. */
607
 
UNIV_INTERN
 
594
 
608
595
void
609
596
os_aio_wake_all_threads_at_shutdown(void);
610
597
/*=====================================*/
611
598
/****************************************************************************
612
599
Waits until there are no pending writes in os_aio_write_array. There can
613
600
be other, synchronous, pending writes. */
614
 
UNIV_INTERN
 
601
 
615
602
void
616
603
os_aio_wait_until_no_pending_writes(void);
617
604
/*=====================================*/
618
605
/**************************************************************************
619
606
Wakes up simulated aio i/o-handler threads if they have something to do. */
620
 
UNIV_INTERN
 
607
 
621
608
void
622
609
os_aio_simulated_wake_handler_threads(void);
623
610
/*=======================================*/
626
613
prefers an i/o-handler thread to handle them all at once later. You must
627
614
call os_aio_simulated_wake_handler_threads later to ensure the threads
628
615
are not left sleeping! */
629
 
UNIV_INTERN
 
616
 
630
617
void
631
618
os_aio_simulated_put_read_threads_to_sleep(void);
632
619
/*============================================*/
639
626
into segments. The thread specifies which segment or slot it wants to wait
640
627
for. NOTE: this function will also take care of freeing the aio slot,
641
628
therefore no other thread is allowed to do the freeing! */
642
 
UNIV_INTERN
 
629
 
643
630
ibool
644
631
os_aio_windows_handle(
645
632
/*==================*/
668
655
/**************************************************************************
669
656
This function is only used in Posix asynchronous i/o. Waits for an aio
670
657
operation to complete. */
671
 
UNIV_INTERN
 
658
 
672
659
ibool
673
660
os_aio_posix_handle(
674
661
/*================*/
684
671
/**************************************************************************
685
672
Does simulated aio. This function should be called by an i/o-handler
686
673
thread. */
687
 
UNIV_INTERN
 
674
 
688
675
ibool
689
676
os_aio_simulated_handle(
690
677
/*====================*/
703
690
        ulint*  type);          /* out: OS_FILE_WRITE or ..._READ */
704
691
/**************************************************************************
705
692
Validates the consistency of the aio system. */
706
 
UNIV_INTERN
 
693
 
707
694
ibool
708
695
os_aio_validate(void);
709
696
/*=================*/
710
697
                                /* out: TRUE if ok */
711
698
/**************************************************************************
712
699
Prints info of the aio arrays. */
713
 
UNIV_INTERN
 
700
 
714
701
void
715
702
os_aio_print(
716
703
/*=========*/
717
704
        FILE*   file);  /* in: file where to print */
718
705
/**************************************************************************
719
706
Refreshes the statistics used to print per-second averages. */
720
 
UNIV_INTERN
 
707
 
721
708
void
722
709
os_aio_refresh_stats(void);
723
710
/*======================*/
726
713
/**************************************************************************
727
714
Checks that all slots in the system have been freed, that is, there are
728
715
no pending io operations. */
729
 
UNIV_INTERN
 
716
 
730
717
ibool
731
718
os_aio_all_slots_free(void);
732
719
/*=======================*/
734
721
 
735
722
/***********************************************************************
736
723
This function returns information about the specified file */
737
 
UNIV_INTERN
738
724
ibool
739
725
os_file_get_status(
740
726
/*===============*/
744
730
        os_file_stat_t* stat_info);     /* information of a file in a
745
731
                                        directory */
746
732
 
747
 
#if !defined(UNIV_HOTBACKUP) && !defined(__NETWARE__)
748
 
/*************************************************************************
749
 
Creates a temporary file that will be deleted on close.
750
 
This function is defined in ha_innodb.cc. */
751
 
UNIV_INTERN
752
 
int
753
 
innobase_mysql_tmpfile(void);
754
 
/*========================*/
755
 
                        /* out: temporary file descriptor, or < 0 on error */
756
 
#endif /* !UNIV_HOTBACKUP && !__NETWARE__ */
757
 
 
758
733
#endif