~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2008-10-28 08:36:02 UTC
  • mfrom: (520.4.13 merge-innodb-plugin)
  • Revision ID: brian@tangent.org-20081028083602-0p3zzlhlxr5q2sqo
Merging Monty's work

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