~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/myisam/mi_open.c

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include "myisamdef.h"
19
19
#include <mystrings/m_ctype.h>
20
 
#include <drizzled/util/test.h>
21
20
 
22
21
static void setup_key_functions(MI_KEYDEF *keyinfo);
 
22
#define get_next_element(to,pos,size) \
 
23
  do {                                \
 
24
    memcpy(to, pos, size);            \
 
25
    pos+=size;                        \
 
26
  } while (0)
 
27
 
23
28
 
24
29
#define disk_pos_assert(pos, end_pos) \
25
30
if (pos > end_pos)             \
91
96
    share_buff.key_cache= multi_key_cache_search((unsigned char*) name_buff,
92
97
                                                 strlen(name_buff));
93
98
 
94
 
    if ((kfile=my_open(name_buff,(open_mode=O_RDWR),MYF(0))) < 0)
 
99
    if ((kfile=my_open(name_buff,(open_mode=O_RDWR) | O_SHARE,MYF(0))) < 0)
95
100
    {
96
101
      if ((errno != EROFS && errno != EACCES) ||
97
102
          mode != O_RDONLY ||
98
 
          (kfile=my_open(name_buff,(open_mode=O_RDONLY),MYF(0))) < 0)
 
103
          (kfile=my_open(name_buff,(open_mode=O_RDONLY) | O_SHARE,MYF(0))) < 0)
99
104
        goto err;
100
105
    }
101
106
    share->mode=open_mode;
855
860
  mi_int2store(ptr,base->max_key_length);               ptr +=2;
856
861
  mi_int2store(ptr,base->extra_alloc_bytes);            ptr +=2;
857
862
  *ptr++= base->extra_alloc_procent;
858
 
  /* old raid info  slots */
859
 
  *ptr++= 0;
860
 
  mi_int2store(ptr,UINT16_C(0));                        ptr +=2;
861
 
  mi_int4store(ptr,UINT32_C(0));                        ptr +=4;
862
 
 
 
863
  *ptr++= base->raid_type;
 
864
  mi_int2store(ptr,base->raid_chunks);                  ptr +=2;
 
865
  mi_int4store(ptr,base->raid_chunksize);               ptr +=4;
863
866
  memset(ptr, 0, 6);                                    ptr +=6; /* extra */
864
867
  return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0;
865
868
}
891
894
  base->max_key_length = mi_uint2korr(ptr);             ptr +=2;
892
895
  base->extra_alloc_bytes = mi_uint2korr(ptr);          ptr +=2;
893
896
  base->extra_alloc_procent = *ptr++;
894
 
 
895
 
  /* advance past raid_type (1) raid_chunks (2) and raid_chunksize (4) */
896
 
  ptr+= 7; 
 
897
  base->raid_type= *ptr++;
 
898
  base->raid_chunks= mi_uint2korr(ptr);                 ptr +=2;
 
899
  base->raid_chunksize= mi_uint4korr(ptr);              ptr +=4;
 
900
  /* TO BE REMOVED: Fix for old RAID files */
 
901
  if (base->raid_type == 0)
 
902
  {
 
903
    base->raid_chunks=0;
 
904
    base->raid_chunksize=0;
 
905
  }
897
906
 
898
907
  ptr+=6;
899
908
  return ptr;
1034
1043
}
1035
1044
 
1036
1045
/**************************************************************************
1037
 
Open data file
 
1046
Open data file with or without RAID
1038
1047
We can't use dup() here as the data file descriptors need to have different
1039
1048
active seek-positions.
1040
1049
 
1045
1054
int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share,
1046
1055
                     File file_to_dup __attribute__((unused)))
1047
1056
{
1048
 
    info->dfile=my_open(share->data_file_name, share->mode,
 
1057
    info->dfile=my_open(share->data_file_name, share->mode | O_SHARE,
1049
1058
                        MYF(MY_WME));
1050
1059
  return info->dfile >= 0 ? 0 : 1;
1051
1060
}
1053
1062
 
1054
1063
int mi_open_keyfile(MYISAM_SHARE *share)
1055
1064
{
1056
 
  if ((share->kfile=my_open(share->unique_file_name, share->mode,
 
1065
  if ((share->kfile=my_open(share->unique_file_name, share->mode | O_SHARE,
1057
1066
                            MYF(MY_WME))) < 0)
1058
1067
    return 1;
1059
1068
  return 0;