Пример #1
0
/*
 * Set status of entry/binfmt_misc:
 * '1' enables, '0' disables and '-1' clears entry/binfmt_misc
 */
static int proc_write_status(struct file *file, const char *buffer,
			     unsigned long count, void *data)
{
	struct binfmt_entry *e;
	int res = count;

	if (buffer[count-1] == '\n')
		count--;
	if ((count == 1) && !(buffer[0] & ~('0' | '1'))) {
		if (data) {
			if ((e = get_entry((long) data)))
				e->flags = (e->flags & ~ENTRY_ENABLED)
					    | (int)(buffer[0] - '0');
			put_entry(e);
		} else {
			enabled = buffer[0] - '0';
		}
	} else if ((count == 2) && (buffer[0] == '-') && (buffer[1] == '1')) {
		if (data)
			clear_entry((long) data);
		else
			clear_entries();
	} else {
		res = -EINVAL;
	}
	return res;
}
Пример #2
0
/*
 * Adds an entry to the flow table. It first checks if the table is full, and
 * if so, it calls clear_entries() to free up space.
 */
static int
table_add_entry(struct onvm_ft_ipv4_5tuple* key, struct flow_info **flow) {
        struct flow_info *data = NULL;

        if (unlikely(key == NULL || lb == NULL)) {
                return -1;
        }

        if (TABLE_SIZE - 1 - lb->num_stored == 0) {
                int ret = clear_entries();
                if (ret < 0) {
                        return -1;
                }
        }

        int tbl_index = onvm_ft_add_key(lb->ft, key, (char **)&data);
        if (tbl_index < 0) {
                return -1;
        }

        lb->num_stored++;
        data->dest = lb->num_stored % lb->server_count;
        data->last_pkt_cycles = lb->elapsed_cycles;
        data->is_active = 0;
        
        *flow = data;

        return 0;
}
Пример #3
0
static void __exit exit_misc_binfmt(void)
{
	unregister_binfmt(&misc_format);
	remove_proc_entry("register", bm_dir);
	remove_proc_entry("status", bm_dir);
	clear_entries();
	remove_proc_entry("sys/fs/binfmt_misc", NULL);
}
Пример #4
0
void
sel4utils_unmap_pages(vspace_t *vspace, void *vaddr, size_t num_pages, size_t size_bits, vka_t *vka)
{
    uintptr_t v = (uintptr_t) vaddr;
    sel4utils_alloc_data_t *data = get_alloc_data(vspace);
    sel4utils_res_t *reserve = find_reserve(data, v);

    if (!sel4_valid_size_bits(size_bits)) {
        ZF_LOGE("Invalid size_bits %zu", size_bits);
        return;
    }

    if (vka == VSPACE_FREE) {
        vka = data->vka;
    }

    for (int i = 0; i < num_pages; i++) {
        seL4_CPtr cap = get_cap(data->top_level, v);

        /* unmap */
        if (cap != 0) {
            int error = seL4_ARCH_Page_Unmap(cap);
            if (error != seL4_NoError) {
                ZF_LOGE("Failed to unmap page at vaddr %p", vaddr);
            }
        }

        if (vka) {
            cspacepath_t path;
            vka_cspace_make_path(vka, cap, &path);
            vka_cnode_delete(&path);
            vka_cspace_free(vka, cap);
            if (sel4utils_get_cookie(vspace, vaddr)) {
                vka_utspace_free(vka, kobject_get_type(KOBJECT_FRAME, size_bits),
                                     size_bits, sel4utils_get_cookie(vspace, vaddr));
            }
        }

        if (reserve == NULL) {
            clear_entries(vspace, v, size_bits);
        } else {
            reserve_entries(vspace, v, size_bits);
        }
        assert(get_cap(data->top_level, v) != cap);
        assert(get_cookie(data->top_level, v) == 0);

        v += (1 << size_bits);
        vaddr = (void *) v;
    }
}
Пример #5
0
static int tree_parse_buffer(git_tree *tree, char *buffer, char *buffer_end)
{
	static const size_t avg_entry_size = 40;
	unsigned int expected_size;
	int error = GIT_SUCCESS;

	expected_size = (tree->object.source.raw.len / avg_entry_size) + 1;

	clear_entries(tree);

	while (buffer < buffer_end) {
		git_tree_entry *entry;

		entry = git__malloc(sizeof(git_tree_entry));
		if (entry == NULL) {
			error = GIT_ENOMEM;
			break;
		}

		if (git_vector_insert(&tree->entries, entry) < GIT_SUCCESS)
			return GIT_ENOMEM;

		entry->owner = tree;
		entry->attr = strtol(buffer, &buffer, 8);

		if (*buffer++ != ' ') {
			error = GIT_EOBJCORRUPTED;
			break;
		}

		if (memchr(buffer, 0, buffer_end - buffer) == NULL) {
			error = GIT_EOBJCORRUPTED;
			break;
		}

		entry->filename = git__strdup(buffer);

		while (buffer < buffer_end && *buffer != 0)
			buffer++;

		buffer++;

		git_oid_mkraw(&entry->oid, (const unsigned char *)buffer);
		buffer += GIT_OID_RAWSZ;
	}

	return error;
}
Пример #6
0
static int free_irte(int irq)
{
	struct irq_2_iommu *irq_iommu = irq_2_iommu(irq);
	unsigned long flags;
	int rc;

	if (!irq_iommu)
		return -1;

	raw_spin_lock_irqsave(&irq_2_ir_lock, flags);

	rc = clear_entries(irq_iommu);

	irq_iommu->iommu = NULL;
	irq_iommu->irte_index = 0;
	irq_iommu->sub_handle = 0;
	irq_iommu->irte_mask = 0;

	raw_spin_unlock_irqrestore(&irq_2_ir_lock, flags);

	return rc;
}
int free_irte(int irq)
{
	int rc = 0;
	struct irq_2_iommu *irq_iommu;
	unsigned long flags;

	spin_lock_irqsave(&irq_2_ir_lock, flags);
	irq_iommu = valid_irq_2_iommu(irq);
	if (!irq_iommu) {
		spin_unlock_irqrestore(&irq_2_ir_lock, flags);
		return -1;
	}

	rc = clear_entries(irq_iommu);

	irq_iommu->iommu = NULL;
	irq_iommu->irte_index = 0;
	irq_iommu->sub_handle = 0;
	irq_iommu->irte_mask = 0;

	spin_unlock_irqrestore(&irq_2_ir_lock, flags);

	return rc;
}
Пример #8
0
SIGNAL_CALLBACK void
on_add_file_with_ancillary_ok_button_clicked(GtkWidget * w)
{
  const char *type = get_string_from_label("add_with_ancillary_format_label");
  int sel = -1;
  if (strcmp_case(type, "GAMMA") == 0)
    sel = ADD_FILE_WITH_ANCILLARY_FORMAT_GAMMA;
  else if (strcmp_case(type, "PolSARPro") == 0)
    sel = ADD_FILE_WITH_ANCILLARY_FORMAT_POLSARPRO;
  else if (strcmp_case(type, "UAVSAR") == 0)
    sel = ADD_FILE_WITH_ANCILLARY_FORMAT_UAVSAR;
  GtkTreeIter iter;
  int ok = TRUE;
  char *dataFile = NULL, *data = NULL, *ceos = NULL;
  char *aux_info = "";

  switch (sel) {
  case ADD_FILE_WITH_ANCILLARY_FORMAT_POLSARPRO:
    {
      GtkWidget *ok_button =
        get_widget_checked("add_file_with_ancillary_ok_button");
      gtk_widget_set_sensitive(ok_button, FALSE);
      dataFile = get_string_from_entry("add_file_with_ancillary_polsarpro_image_entry");
      char *matrixType=NULL, *error, *decompositionType, *derror;
      char *serror, *perror;
      int is_polsarpro_matrix =
        isPolsarproMatrix(dataFile, &matrixType, &error);
      int is_polsarpro_decomposition =
        isPolsarproDecomposition(dataFile, &decompositionType, &derror);
      int is_polsarpro_segmentation =
        isPolsarproSegmentation(dataFile, &serror);
      int is_polsarpro_parameter = isPolsarproParameter(dataFile, &perror);
      if (is_polsarpro_matrix && !is_polsarpro_decomposition &&
          !is_polsarpro_segmentation && !is_polsarpro_parameter) {
        data = (char *) MALLOC(sizeof(char) * (strlen(dataFile) + 15));
        if (!is_dir(dataFile)) {
          char *tmp = (char *) MALLOC(sizeof(char) * (strlen(dataFile) + 1));
          tmp = get_dirname(dataFile);
          dataFile[strlen(tmp) - 1] = '\0';
          FREE(tmp);
        }
        if (strcmp(matrixType, "T3") == 0 || strcmp(matrixType, "T4") == 0)
          sprintf(data, "%s/T11.bin", dataFile);
        else if (strcmp(matrixType, "C2") == 0 ||
                 strcmp(matrixType, "C3") == 0 ||
                 strcmp(matrixType, "C4") == 0)
          sprintf(data, "%s/C11.bin", dataFile);
      }
      else
        data = STRDUP(dataFile);
      FREE(matrixType);
      int is_geocoded = isGeocoded(data);
      if (!is_geocoded)
        ceos =
          get_string_from_entry
          ("add_file_with_ancillary_polsarpro_ceos_entry");
      if (!is_geocoded && (strlen(ceos) == 0 || strlen(data) == 0)) {
        put_string_to_label("add_with_ancillary_error_label",
                            "Please choose all required files!");
        return;
      }
      else {
        GtkWidget *browse_option_menu =
          get_widget_checked("browse_select_colormap_optionmenu");
        GtkWidget *menu =
          gtk_option_menu_get_menu(GTK_OPTION_MENU(browse_option_menu));
        GtkWidget *selected_item = gtk_menu_get_active(GTK_MENU(menu));
        GtkWidget *combo =
          get_widget_checked("browse_select_image_data_type_optionmenu");
        int image_data_type = gtk_combo_box_get_active(GTK_COMBO_BOX(combo));
        char *lut_basename =
          g_object_get_data(G_OBJECT(selected_item), "file");
        aux_info = encode_polsarpro_aux_info(image_data_type, lut_basename);
        put_string_to_label("add_with_ancillary_error_label", "");
        ok = add_to_files_list_iter(data, ceos, NULL, aux_info, NULL,
                                    NULL, NULL, NULL, NULL, &iter);

        free(aux_info);
      }
      break;
    }

  case ADD_FILE_WITH_ANCILLARY_FORMAT_GAMMA:
    {
      GtkWidget *ok_button =
        get_widget_checked("add_file_with_ancillary_ok_button");
      gtk_widget_set_sensitive(ok_button, TRUE);
      data =
        get_string_from_entry("add_file_with_ancillary_gamma_data_entry");
      char *meta =
        get_string_from_entry("add_file_with_ancillary_gamma_metadata_entry");
      if (strlen(data) == 0 || strlen(meta) == 0) {
        put_string_to_label("add_with_ancillary_error_label",
                            "Please choose all required files!");
        return;
      }
      else {
        put_string_to_label("add_with_ancillary_error_label", "");
        char *interferogram, *coherence, *slave_metadata, *baseline;
        interferogram = get_string_from_entry("add_file_with_ancillary_gamma_igram_entry");
        coherence = get_string_from_entry("add_file_with_ancillary_gamma_coh_entry");
        slave_metadata = get_string_from_entry("add_file_with_ancillary_gamma_slave_entry");
        baseline = get_string_from_entry("add_file_with_ancillary_gamma_baseline_entry");
        if (strlen(interferogram) == 0) {
          FREE(interferogram);
          interferogram = NULL;
        }
        if (strlen(coherence) == 0) {
          FREE(coherence);
          coherence = NULL;
        }
        if (strlen(slave_metadata) == 0) {
          FREE(slave_metadata);
          slave_metadata = NULL;
        }
        if (strlen(baseline) == 0) {
          FREE(baseline);
          baseline = NULL;
        }
        ok = add_to_files_list_iter(data, ceos, meta, aux_info, NULL,
                                    interferogram, coherence,
                                    slave_metadata, baseline, &iter);
      }
      break;
    }

    case ADD_FILE_WITH_ANCILLARY_FORMAT_UAVSAR:
    {
      GtkWidget *ok_button =
        get_widget_checked("add_file_with_ancillary_ok_button");
      gtk_widget_set_sensitive(ok_button, TRUE);

      GtkWidget *ann_file_entry = get_widget_checked("add_file_with_ancillary_uavsar_annotation_file_entry");
      const gchar *annotation_file = gtk_entry_get_text(GTK_ENTRY(ann_file_entry));

      GList *l, *uavsar_proc_types = get_widgets_prefix_checked("uavsar_proc_type_");
      for(l = uavsar_proc_types; l; l = l->next) {
        gpointer proc_type_check_button = l->data;
        if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(proc_type_check_button))) {
          const gchar *name = gtk_widget_get_name(GTK_WIDGET(proc_type_check_button));
          ok = add_to_files_list_iter(annotation_file, NULL, NULL, NULL, name + strlen("uavsar_proc_types_") - 1,
              NULL, NULL, NULL, NULL, &iter);
          if(!ok)
            break;
        }
      }
      g_list_free(uavsar_proc_types);
    }
    break;
  }
  if (!ok) {
    if (data) {
      char *msg = MALLOC(sizeof(char) * (strlen(data) + 128));
      sprintf(msg, "Unrecognized file:\n  %s\n\n"
              "The file may be of a type not supported by MapReady.\n", data);
      message_box(msg);
      free(msg);
    }
    else {
      char *msg = MALLOC(sizeof(char) * 256);
      sprintf(msg, "Unrecognized file!\n\n"
              "The file may be of a type not supported by MapReady.\n");
      message_box(msg);
      free(msg);
    }
  }
  else {
    show_widget("add_file_with_ancillary_dialog", FALSE);
    clear_entries();
  }
}
Пример #9
0
SIGNAL_CALLBACK void
on_add_file_with_ancillary_dialog_delete_event(GtkWidget *widget)
{
  clear_entries();
  show_widget("add_file_with_ancillary_dialog", FALSE);
}
Пример #10
0
SIGNAL_CALLBACK void
on_add_file_with_ancillary_cancel_button_clicked(GtkWidget *w)
{
  clear_entries();
  show_widget("add_file_with_ancillary_dialog", FALSE);
}
Пример #11
0
void git_tree__free(git_tree *tree)
{
	clear_entries(tree);
	git_vector_free(&tree->entries);
	free(tree);
}