Skip to content

Commit fd410cb

Browse files
author
Chameleon Cloud User
committed
When managed fileops is NULL, initialize
1 parent e18bb8f commit fd410cb

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

splitfs/fileops_hub.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ int hub_check_resolve_fileops(char* tree);
3333
void _hub_init2(void);
3434

3535
#define HUB_CHECK_RESOLVE_FILEOPS(NAME, FUNCT) \
36-
assert( _hub_managed_fileops != NULL ); \
36+
if (_hub_managed_fileops == NULL && _hub_fileops == NULL) \
37+
_hub_init(); \
38+
assert( _hub_managed_fileops != NULL ); \
3739
assert( _hub_fileops != NULL );
3840

3941
#define HUB_ADD_FUNCTP(SOFILE, FUNCT) \
@@ -559,24 +561,25 @@ void _hub_add_fileop(struct Fileops_p* fo)
559561

560562
DEBUG("Registering Fileops_p \"%s\" at index %i\n",
561563
fo->name, _hub_fileops_count);
562-
564+
563565
int i=0;
564566
for(i=0; i<_hub_fileops_count; i++)
565567
{
566568
if(!strcmp(_hub_fileops_lookup[i]->name, fo->name))
567569
{
568-
ERROR("Can't add fileop %s: one with the same name already exists at index %i\n", fo->name, i);
569-
assert(0);
570+
MSG("Can't add fileop %s: one with the same name already exists at index %i\n", fo->name, i);
571+
//assert(0);
572+
return;
570573
}
571574
}
572-
575+
573576
if(_hub_fileops_count >= MAX_FILEOPS) {
574577
ERROR("_hub_fileops_lookup is full: too many Fileops_p!\n");
575578
ERROR("Maximum supported: %i\n", MAX_FILEOPS);
576579
ERROR("Check fileops_compareharness.c to increase\n");
577580
return;
578581
}
579-
582+
580583
_hub_fileops_lookup[_hub_fileops_count] = fo;
581584
_hub_fileops_count++;
582585
}
@@ -1030,22 +1033,22 @@ RETT_SHM_COPY _hub_SHM_COPY() {
10301033

10311034
munmap(shm_area, 1024*1024);
10321035
shm_unlink(exec_hub_filename);
1033-
1036+
10341037
return _hub_managed_fileops->SHM_COPY();
10351038
}
10361039

10371040

1038-
#ifdef TRACE_FP_CALLS
1041+
#ifdef TRACE_FP_CALLS
10391042
RETT_FOPEN _hub_FOPEN(INTF_FOPEN)
10401043
{
10411044
HUB_CHECK_RESOLVE_FILEOPS(_hub_, FOPEN);
10421045

10431046
DEBUG_FILE("CALL: _hub_FOPEN for %s\n", path);
1044-
1045-
FILE *fp = NULL;
1047+
1048+
FILE *fp = NULL;
10461049
int fd = -1, oflag = 0;
10471050
int num_mode_chars = 0;
1048-
1051+
10491052
if ((mode[0] == 'w' || mode[0] == 'a') && mode[1] == '+') {
10501053
oflag |= O_RDWR;
10511054
oflag |= O_CREAT;
@@ -1058,7 +1061,7 @@ RETT_FOPEN _hub_FOPEN(INTF_FOPEN)
10581061
else if (mode[0] == 'w' || mode[0] == 'a') {
10591062
oflag |= O_WRONLY;
10601063
oflag |= O_CREAT;
1061-
num_mode_chars += 2;
1064+
num_mode_chars += 2;
10621065
}
10631066
else if (mode[0] == 'r') {
10641067
oflag |= O_RDONLY;
@@ -1068,7 +1071,7 @@ RETT_FOPEN _hub_FOPEN(INTF_FOPEN)
10681071
assert(0);
10691072
}
10701073

1071-
1074+
10721075
if (mode[0] == 'a') {
10731076
oflag |= O_APPEND;
10741077
num_mode_chars++;

0 commit comments

Comments
 (0)