Esempio n. 1
0
int main(void)
{
    tm4c123_spi_initialize();

    {
	F_FILE *file;
	unsigned int n;
	uint8_t data[512];

	f_initvolume();

	file = f_open("LOG00000.DAT", "w,32M");

	if (file)
	{
	    f_flush(file);

	    memset(data, 0xaa, sizeof(data));

	    for (n = 0; n < (32 * 1024 * 1024 / 512); n++)
	    {
		f_write(data, 512, 1, file);
	    }
  
	    f_close(file);
	}

	f_delvolume();
    }

    while (1) { };
}
Esempio n. 2
0
/*
 * NAME:	hfs->close()
 * DESCRIPTION:	close a file
 */
int hfs_close(hfsfile *file)
{
  hfsvol *vol = file->vol;
  int result = 0;

  if (--(file->refs)) {
    // File still has more refs
	printf("file %s still has %d refs\n", file->name, file->refs);
	return 0;
  }
	
  if (f_trunc(file) == -1 ||
      f_flush(file) == -1)
    result = -1;

  if (file->prev)
    file->prev->next = file->next;
  if (file->next)
    file->next->prev = file->prev;
  if (file == vol->files)
    vol->files = file->next;

  FREE(file);

  return result;
}
Esempio n. 3
0
bool TestExtOutput::test_flush() {
  f_ob_start();
  f_ob_start("strtolower");
  g_context->write(""); // we can't really verify what's written to stdout
  f_flush();
  f_ob_end_clean();
  f_ob_end_clean();
  return Count(true);
}
Esempio n. 4
0
/* Child process monitoring function */
void *process_monitor() {
  pid_t child_pid; /* pid of zombie child */
  int status, time_interval; /* child exit status; interval between time_t's */
  
  while(true) {
    
    mutex_lock(&g_mutex);
    if(g_num_children > 0) {
      mutex_unlock(&g_mutex);
      
      child_pid = wait(&status);
      
      if(child_pid < 0) {
          if(errno == EINTR) /* Waiting interrupted */
            continue;
          else
            handle_error("wait");
      }
      
      mutex_lock(&g_mutex);
      time_interval = update_terminated_process(g_lst_children,
        child_pid, status, time(NULL));
      
      if(time_interval < 0) {
        fprintf(stderr, "update_terminated_process: interval is negative\n");
        fprintf(stderr, "Not logging process %d..\n", child_pid);
      } else {
        g_total_time += time_interval;
  
        fprintf(g_log_file, "iteracao %d\n" \
                "PID: %d execution time: %02d s\n" \
                "total execution time: %02d s\n",
                g_iterations++, child_pid, time_interval, g_total_time);
        f_flush(g_log_file);
      }
      --g_num_children;
      
      cond_signal(&g_child_cv);
      mutex_unlock(&g_mutex);
      
    } else if(g_monitoring) {
      while(g_num_children == 0 && g_monitoring)
        cond_wait(&g_monitoring_cv, &g_mutex);
      mutex_unlock(&g_mutex);
    }
    else break;
  }
  mutex_unlock(&g_mutex);
  
  return NULL;
}
Esempio n. 5
0
/*
 * NAME:	hfs->flush()
 * DESCRIPTION:	flush all pending changes to an HFS volume
 */
int hfs_flush(hfsvol *vol)
{
  hfsfile *file;

  if (v_getvol(&vol) < 0)
    return -1;

  for (file = vol->files; file; file = file->next)
    {
      if (f_flush(file) < 0)
	return -1;
    }

  if (v_flush(vol, 0) < 0)
    return -1;

  return 0;
}
Esempio n. 6
0
/*
 * NAME:	hfs->close()
 * DESCRIPTION:	close a file
 */
int hfs_close(hfsfile *file)
{
  hfsvol *vol = file->vol;
  int result = 0;

  if (f_trunc(file) == -1 ||
      f_flush(file) == -1)
    result = -1;

  if (file->prev)
    file->prev->next = file->next;
  if (file->next)
    file->next->prev = file->prev;
  if (file == vol->files)
    vol->files = file->next;

  FREE(file);

  return result;
}
Esempio n. 7
0
/*
 * NAME:	hfs->flush()
 * DESCRIPTION:	flush all pending changes to an HFS volume
 */
int hfs_flush(hfsvol *vol)
{
  hfsfile *file;

  if (getvol(&vol) == -1)
    goto fail;

  for (file = vol->files; file; file = file->next)
    {
      if (f_flush(file) == -1)
	goto fail;
    }

  if (v_flush(vol) == -1)
    goto fail;

  return 0;

fail:
  return -1;
}