Exemplo n.º 1
0
Arquivo: font.c Projeto: rxi/lovedos
const char *font_init(font_t *self, const char *filename, int ptsize) {
  const char *errmsg = NULL;
  void *data = NULL;
  FILE *fp = NULL;
  memset(self, 0, sizeof(*self));

  /* Load font file */
  int size;
  data = filesystem_read(filename, &size);
  if (!data) {
    errmsg = "could not open font file";
    goto fail;
  }

  /* Init font */
  errmsg = initFont(self, data, ptsize);
  if (errmsg) {
    goto fail;
  }

  /* Free font data */
  filesystem_free(data);
  data = NULL;

  return NULL;

fail:
  if (fp) fclose(fp);
  filesystem_free(data);
  return errmsg;
}
Exemplo n.º 2
0
Arquivo: main.c Projeto: jucs/musicfs
static void fuse_destroyed() {	
	logging_log("Main", LOGGING_LEVEL_INFO,
			"*** Got EXIT COMMAND from FUSE, termination sequence initiated...");
	
	logging_log("Main", LOGGING_LEVEL_INFO,
			"Terminating all other threads...");
	
	downloader_shutdown();
	
	logging_log("Main", LOGGING_LEVEL_INFO,
			"All other threads have terminated, cleaning up...");
	
	http_free();
	downloader_free();
	searcher_free();
	filesystem_free();
	providers_free();
	configuration_free();
	
	logging_log("Main", LOGGING_LEVEL_INFO,
			"Cleanup almost finished, cleaning up the logging subsystem and exiting...");
	logging_free();
	
	fclose(stdin);
	fclose(stdout);
	fclose(stderr);
}
Exemplo n.º 3
0
static int tmpfs_mount(void *dev, void *dir) {
	struct node *dir_node, *dev_node;
	struct nas *dir_nas, *dev_nas;
	struct tmpfs_file_info *fi;
	struct tmpfs_fs_info *fsi;
	struct node_fi *dev_fi;

	dev_node = dev;
	dev_nas = dev_node->nas;
	dir_node = dir;
	dir_nas = dir_node->nas;

	if (NULL == (dev_fi = dev_nas->fi)) {
		return -ENODEV;
	}

	if (NULL == (dir_nas->fs = filesystem_create("tmpfs"))) {
		return -ENOMEM;
	}
	dir_nas->fs->bdev = dev_fi->privdata;

	/* allocate this fs info */
	if(NULL == (fsi = pool_alloc(&tmpfs_fs_pool))) {
		filesystem_free(dir_nas->fs);
		return -ENOMEM;
	}
	memset(fsi, 0, sizeof(struct tmpfs_fs_info));
	dir_nas->fs->fsi = fsi;

	fsi->block_per_file = MAX_FILE_SIZE;
	fsi->block_size = PAGE_SIZE();
	fsi->numblocks = block_dev(dev_fi->privdata)->size / PAGE_SIZE();

	/* allocate this directory info */
	if(NULL == (fi = pool_alloc(&tmpfs_file_pool))) {
		return -ENOMEM;
	}
	memset(fi, 0, sizeof(struct tmpfs_file_info));
	fi->index = fi->mode = 0;
	dir_nas->fi->privdata = (void *) fi;

	return 0;
}
Exemplo n.º 4
0
Arquivo: main.c Projeto: zbierak/ipa
int main(int argc, char* argv[])
{
	if (argc != 2)
	{
		LOG_ERROR("Usage: %s <mount location>", argv[0]);
		return 1;
	}

	filesystem_h fs = filesystem_create();

	device_h* devices = NULL;
	size_t devices_count = 0;

	if (get_available_devices(&devices, &devices_count))
	{
		for (size_t i = 0; i < devices_count; i++)
		{
			LOG_INFO("Found device %s (%s)", device_get_uid(devices[i]), device_get_name(devices[i]));

			char* db_location = device_get_photo_db_location(devices[i]);
			char* root_path = device_get_root_path(devices[i]);
			db_h db = db_create(db_location, device_get_name(devices[i]), root_path);

			if (db != NULL)
			{
				filesystem_add_database(fs, db);
			}

			free(db_location);
			free(root_path);
			device_free(devices[i]);
		}

		free(devices);
	}

	filesystem_run(fs, argv[1]);

	filesystem_free(fs);
}