Exemplo n.º 1
0
int chgrp_cmd(int argc, char **argv) {
    if (argc == 2) {
        TTY* tty = tty_getCurrentTTY();
        u32int currentiNode = tty->currDirectory;
        fs_node_t current;
        fs_getFsNode(&current, currentiNode);
        fs_node_t* file = finddir_fs(&current, argv[1]);
        if (file == NULL) {
            printf("chown: No such file or directory %s.\n", argv[1]);
            kfree(file);
            return -1;
        }
        if (!permission_file_isOwner(file)) {
            printf("chown: You are not the owner of %s.\n", argv[1]);
            kfree(file);
            return -2;
        }
        errno = OK;
        int gid = group_find(argv[0]);
        if (gid == NO_GROUP) {
            printf("chown: Group %s does not exist.\n", argv[0]);
            kfree(file);
            return -2;
        } else {
            fs_setFileGid(file->inode, gid);
            if (errno != OK) {
                printf ("ERROR %d", errno);
            }
        }
        kfree(file);
    } else {
        printf("Usage: chmod OCTALMODE FILE");
    }
    return 0;
}
Exemplo n.º 2
0
/*
 * Parse a line from the newsrc file and write it back out with updated
 * sequence information. Return number of lines written (ie, 0 or 1)
 */
static int
write_newsrc_line(
	FILE *fp,
	char *line)
{
	char *seq;
	int sub;
	struct t_group *group;

	seq = parse_newsrc_line(line, &sub);

	if (line[0] == '\0' || sub == 0)		/* Insurance against blank line */
		return 0;

	if (seq == NULL) {		/* line has no ':' or '!' in it */
		if (tinrc.strip_bogus == BOGUS_REMOVE)
			wait_message(2, _(txt_remove_bogus), line);
		return 0;
	}

	/*
	 * Find the group in active. If we cannot, then junk it if bogus groups
	 * are set to auto removal. Also check for bogus flag just in case
	 * strip_bogus was changed since tin started
	 */
	group = group_find(line);

	if (tinrc.strip_bogus == BOGUS_REMOVE) {
		if (group == NULL || group->bogus) { /* group dosen't exist */
			wait_message(2, _(txt_remove_bogus), line);
			return 0;
		}
	}

	if ((group && group->newsrc.present) && (group->subscribed || !tinrc.strip_newsrc)) {
		fprintf(fp, "%s%c ", group->name, SUB_CHAR(group->subscribed));
		print_bitmap_seq(fp, group);
		return 1;
	} else {
		if (sub == SUBSCRIBED || !tinrc.strip_newsrc) {
			fprintf(fp, "%s%c %s\n", line, sub, seq);
			return 1;
		}
	}
	return 0;
}
Exemplo n.º 3
0
void group_assigngid(FAR struct task_group_s *group)
{
  irqstate_t flags;
  gid_t gid;

  /* Pre-emption should already be enabled, but lets be paranoid careful */

  sched_lock();

  /* Loop until we create a unique ID */

  for (;;)
    {
      /* Increment the ID counter.  This is global data so be extra paraoid. */

      flags = irqsave();
      gid = ++g_gidcounter;

      /* Check for overflow */

      if (gid <= 0)
        {
          g_gidcounter = 1;
          irqrestore(flags);
        }
      else
        {
          /* Does a task group with this ID already exist? */

          irqrestore(flags);
          if (group_find(gid) == NULL)
            {
              /* Now assign this ID to the group and return */

              group->tg_gid = gid;
              sched_unlock();
              return;
            }
        }
    }
}
Exemplo n.º 4
0
/*
 * Automatically subscribe user to newsgroups specified in
 * NEWSLIBDIR/subscriptions (locally) or same file but from NNTP
 * server (LIST SUBSCRIPTIONS) and create .newsrc
 */
static void
auto_subscribe_groups(
	char *newsrc_file)
{
	FILE *fp_newsrc;
	FILE *fp_subs;
	char *ptr;

	/*
	 * If subscription file exists then first unsubscribe to all groups
	 * and then subscribe to just the auto specified groups.
	 */
	if ((fp_subs = open_subscription_fp()) == NULL)
		return;

	if (!batch_mode)
		wait_message(0, _(txt_autosubscribing_groups));

	if ((fp_newsrc = fopen(newsrc_file, "w" FOPEN_OPTS)) == NULL)
		return;

#ifndef M_OS2
	if (newsrc_mode)
		fchmod(fileno(fp_newsrc), newsrc_mode);
#endif /* !M_OS2 */

	/* TODO: test me! */
	while ((ptr = tin_fgets(fp_subs, FALSE)) != NULL) {
		if (ptr[0] != '#') {
			if (group_find(ptr) != 0)
				fprintf(fp_newsrc, "%s:\n", ptr);
		}
	}

	/* We ignore user 'q'uits here. They will get them next time in any case */

	if (ferror(fp_newsrc) || fclose(fp_newsrc))
		error_message(_(txt_filesystem_full), NEWSRC_FILE);

	TIN_FCLOSE(fp_subs);
}
Exemplo n.º 5
0
char *
group_unset(struct ctl_group_settings *gs, size_t len)
{
	struct group *g;
	size_t i;

	/* Don't allow the controller to mess with internals. */
	if (gs->flags & ~GROUP__CONTROLLER_FLAGS)
		return "you specified some non-controller flags";

	if ((g = group_find(gs->name)) == NULL)
		return "no such group";

	len -= offsetof(struct ctl_group_settings, options);

	/* Wipe all the options the controller wants us to. */
	for (i = 0; i < len; ++i) {
		free(g->options[gs->options[i]]);
		g->options[gs->options[i]] = NULL;
	}

	/* Take care of configuration with special needs. */
	if (gs->flags & GROUP_WANT_NEXT_SERVER)
		g->next_server.s_addr = INADDR_ANY;
	if (gs->flags & GROUP_WANT_FILENAME) {
		free(g->filename);
		g->filename = NULL;
	}
	if (gs->flags & GROUP_WANT_SNAME) {
		free(g->sname);
		g->sname = NULL;
	}

	g->flags &= ~gs->flags;

	return NULL;
}
int pmix_mca_base_var_group_find (const char *project_name,
                             const char *framework_name,
                             const char *component_name)
{
    return group_find (project_name, framework_name, component_name, false);
}
static int group_register (const char *project_name, const char *framework_name,
                           const char *component_name, const char *description)
{
    pmix_mca_base_var_group_t *group;
    int group_id, parent_id = -1;
    int ret;

    if (NULL == project_name && NULL == framework_name && NULL == component_name) {
        /* don't create a group with no name (maybe we should create a generic group?) */
        return -1;
    }

    /* avoid groups of the form pmix_pmix, etc */
    if (NULL != project_name && NULL != framework_name &&
        (0 == strcmp (project_name, framework_name))) {
        project_name = NULL;
    }

    group_id = group_find (project_name, framework_name, component_name, true);
    if (0 <= group_id) {
        ret = pmix_mca_base_var_group_get_internal (group_id, &group, true);
        if (PMIX_SUCCESS != ret) {
            /* something went horribly wrong */
            assert (NULL != group);
            return ret;
        }
        group->group_isvalid = true;
        pmix_mca_base_var_groups_timestamp++;

        /* group already exists. return it's index */
        return group_id;
    }

    group = PMIX_NEW(pmix_mca_base_var_group_t);

    group->group_isvalid = true;

    if (NULL != project_name) {
        group->group_project = strdup (project_name);
        if (NULL == group->group_project) {
            PMIX_RELEASE(group);
            return PMIX_ERR_OUT_OF_RESOURCE;
        }
    }
    if (NULL != framework_name) {
        group->group_framework = strdup (framework_name);
        if (NULL == group->group_framework) {
            PMIX_RELEASE(group);
            return PMIX_ERR_OUT_OF_RESOURCE;
        }
    }
    if (NULL != component_name) {
        group->group_component = strdup (component_name);
        if (NULL == group->group_component) {
            PMIX_RELEASE(group);
            return PMIX_ERR_OUT_OF_RESOURCE;
        }
    }
    if (NULL != description) {
        group->group_description = strdup (description);
        if (NULL == group->group_description) {
            PMIX_RELEASE(group);
            return PMIX_ERR_OUT_OF_RESOURCE;
        }
    }

    if (NULL != framework_name && NULL != component_name) {
        parent_id = group_register (project_name, framework_name, NULL, NULL);
    }

    /* build the group name */
    ret = pmix_mca_base_var_generate_full_name4 (NULL, project_name, framework_name, component_name,
                                            &group->group_full_name);
    if (PMIX_SUCCESS != ret) {
        PMIX_RELEASE(group);
        return ret;
    }

    group_id = pmix_pointer_array_add (&pmix_mca_base_var_groups, group);
    if (0 > group_id) {
        PMIX_RELEASE(group);
        return PMIX_ERROR;
    }

    pmix_hash_table_set_value_ptr (&pmix_mca_base_var_group_index_hash, group->group_full_name,
                                   strlen (group->group_full_name), (void *)(uintptr_t) group_id);

    pmix_mca_base_var_group_count++;
    pmix_mca_base_var_groups_timestamp++;

    if (0 <= parent_id) {
        pmix_mca_base_var_group_t *parent_group;

        (void) pmix_mca_base_var_group_get_internal(parent_id, &parent_group, false);
        pmix_value_array_append_item (&parent_group->group_subgroups, &group_id);
    }

    return group_id;
}
Exemplo n.º 8
0
/*
 * Promote PG above it's current parent.
 * This is only legal if PG has an equal or greater number of CPUs than its
 * parent.
 *
 * This routine operates on the CPU specific processor group data (for the CPUs
 * in the PG being promoted), and may be invoked from a context where one CPU's
 * PG data is under construction. In this case the argument "pgdata", if not
 * NULL, is a reference to the CPU's under-construction PG data.
 */
static void
cmt_hier_promote(pg_cmt_t *pg, cpu_pg_t *pgdata)
{
	pg_cmt_t	*parent;
	group_t		*children;
	cpu_t		*cpu;
	group_iter_t	iter;
	pg_cpu_itr_t	cpu_iter;
	int		r;
	int		err;

	ASSERT(MUTEX_HELD(&cpu_lock));

	parent = pg->cmt_parent;
	if (parent == NULL) {
		/*
		 * Nothing to do
		 */
		return;
	}

	ASSERT(PG_NUM_CPUS((pg_t *)pg) >= PG_NUM_CPUS((pg_t *)parent));

	/*
	 * We're changing around the hierarchy, which is actively traversed
	 * by the dispatcher. Pause CPUS to ensure exclusivity.
	 */
	pause_cpus(NULL);

	/*
	 * If necessary, update the parent's sibling set, replacing parent
	 * with PG.
	 */
	if (parent->cmt_siblings) {
		if (group_remove(parent->cmt_siblings, parent, GRP_NORESIZE)
		    != -1) {
			r = group_add(parent->cmt_siblings, pg, GRP_NORESIZE);
			ASSERT(r != -1);
		}
	}

	/*
	 * If the parent is at the top of the hierarchy, replace it's entry
	 * in the root lgroup's group of top level PGs.
	 */
	if (parent->cmt_parent == NULL &&
	    parent->cmt_siblings != &cmt_root->cl_pgs) {
		if (group_remove(&cmt_root->cl_pgs, parent, GRP_NORESIZE)
		    != -1) {
			r = group_add(&cmt_root->cl_pgs, pg, GRP_NORESIZE);
			ASSERT(r != -1);
		}
	}

	/*
	 * We assume (and therefore assert) that the PG being promoted is an
	 * only child of it's parent. Update the parent's children set
	 * replacing PG's entry with the parent (since the parent is becoming
	 * the child). Then have PG and the parent swap children sets.
	 */
	ASSERT(GROUP_SIZE(parent->cmt_children) <= 1);
	if (group_remove(parent->cmt_children, pg, GRP_NORESIZE) != -1) {
		r = group_add(parent->cmt_children, parent, GRP_NORESIZE);
		ASSERT(r != -1);
	}

	children = pg->cmt_children;
	pg->cmt_children = parent->cmt_children;
	parent->cmt_children = children;

	/*
	 * Update the sibling references for PG and it's parent
	 */
	pg->cmt_siblings = parent->cmt_siblings;
	parent->cmt_siblings = pg->cmt_children;

	/*
	 * Update any cached lineages in the per CPU pg data.
	 */
	PG_CPU_ITR_INIT(pg, cpu_iter);
	while ((cpu = pg_cpu_next(&cpu_iter)) != NULL) {
		int		idx;
		pg_cmt_t	*cpu_pg;
		cpu_pg_t	*pgd;	/* CPU's PG data */

		/*
		 * The CPU's whose lineage is under construction still
		 * references the bootstrap CPU PG data structure.
		 */
		if (pg_cpu_is_bootstrapped(cpu))
			pgd = pgdata;
		else
			pgd = cpu->cpu_pg;

		/*
		 * Iterate over the CPU's PGs updating the children
		 * of the PG being promoted, since they have a new parent.
		 */
		group_iter_init(&iter);
		while ((cpu_pg = group_iterate(&pgd->cmt_pgs, &iter)) != NULL) {
			if (cpu_pg->cmt_parent == pg) {
				cpu_pg->cmt_parent = parent;
			}
		}

		/*
		 * Update the CMT load balancing lineage
		 */
		if ((idx = group_find(&pgd->cmt_pgs, (void *)pg)) == -1) {
			/*
			 * Unless this is the CPU who's lineage is being
			 * constructed, the PG being promoted should be
			 * in the lineage.
			 */
			ASSERT(pg_cpu_is_bootstrapped(cpu));
			continue;
		}

		ASSERT(GROUP_ACCESS(&pgd->cmt_pgs, idx - 1) == parent);
		ASSERT(idx > 0);

		/*
		 * Have the child and the parent swap places in the CPU's
		 * lineage
		 */
		group_remove_at(&pgd->cmt_pgs, idx);
		group_remove_at(&pgd->cmt_pgs, idx - 1);
		err = group_add_at(&pgd->cmt_pgs, parent, idx);
		ASSERT(err == 0);
		err = group_add_at(&pgd->cmt_pgs, pg, idx - 1);
		ASSERT(err == 0);
	}

	/*
	 * Update the parent references for PG and it's parent
	 */
	pg->cmt_parent = parent->cmt_parent;
	parent->cmt_parent = pg;

	start_cpus();
}
Exemplo n.º 9
0
void menu_F1()
{  
char * s; /* pointer to selector */
int g_max;
g_max=group_max(group, vertex_used);

printf("GROUP (F1) MENU:\n");
printf("(maximal group number is: %d)\n\n", g_max);

printf("  =     Print current group statistics\n");  
printf("  cg    Change current group [%d]\n", group_current);
printf("  m     Mark current group [now marked: %d]\n", group_marker);
printf("  -m    Set group marker to -1 (no group)\n");
printf("  m2c   Move vertices from marked group (%d) to current group (%d)\n", group_marker, group_current );
printf("  ex    Extract visible vertices to a new group\n");
printf("  fi    Change to a group incident to the cursor\n");
printf("  cp    Copy to new group\n");  
printf("  cpe   Copy and glue with edges\n");  
printf("  cpt   Copy and glue with triangles\n");  
printf("  cpet  Copy and glue with edges and triangles\n");  
printf("  z     Remove empty groups (renumbers the remaining groups)\n");
printf("  de    Delete edges incident to current group\n");
printf("  dt    Delete triangles incident to current group\n");
printf("  det   Delete edges and triangles incident to current group\n");
printf("  pe    Paint edges of current group with current color\n");
printf("  pt    Paint triangles of current group with current color\n");

printf("  s     Scale\n");
printf("  sx    Scale in X dimmension\n");
printf("  sy    Scale in Y dimmension\n");
printf("  sz    Scale in Z dimmension\n");
printf("  rx    rotate current group 90 degrees around X\n");
printf("  ry    rotate current group 90 degrees around Y\n");
printf("  rz    rotate current group 90 degrees around Z\n");
if(context==context_et0) 
  printf("  mv    move current group by vector (et0_marker, cursor)\n");

s=get_menu_selector();

printf("%s\n", s);

if(strcmp(s,"cg")==0)
	{int g;
	  printf("Input group number (between 0 and %d):\n", g_max+1);
          scanf("%d", &g);
          if(0<=g && g<= g_max+1) 
	    group_change_current(g, &group_current, group, vertex_used); 
	  else printf("bad group number !\n");
	}
else
if(strcmp(s,"s")==0)
	{float s;
	printf("Input scaling factor:\n");
	s=get_float();
	backup();
	group_scale(group_current, s, s, s, cursor,
		    group, vertex, vertex_used);
	}
else
if(strcmp(s,"sx")==0)
	{float s;
	printf("Input scaling factor:\n");
	s=get_float();
	backup();
	group_scale(group_current, s, 1.0, 1.0, cursor,
		    group, vertex, vertex_used);
	}
else
if(strcmp(s,"sy")==0)
	{float s;
	printf("Input scaling factor:\n");
	s=get_float();
	backup();
	group_scale(group_current, 1.0, s, 1.0, cursor,
		    group, vertex, vertex_used);
	}
else
if(strcmp(s,"sz")==0)
	{float s;
	printf("Input scaling factor:\n");
	s=get_float();
	backup();
	group_scale(group_current, 1.0, 1.0, s, cursor,
		    group, vertex, vertex_used);
	}
else
if(strcmp(s,"ry")==0){
      backup();
      group_rot90(group_current, 0, 1, 0);
} else
if(strcmp(s,"rx")==0){
      backup();
      group_rot90(group_current, 1, 0, 0);
} else
if(strcmp(s,"rz")==0){
      backup();
      group_rot90(group_current, 0, 0, 1);
} else
if(strcmp(s,"=")==0){
      group_statistics(group_current); 
      /* get_anything(); */
      get_enter();
} else
if(strcmp(s,"ex")==0){
      backup();
      group_extract_clipped();
} else
if(strcmp(s,"m")==0){
	  group_mark(group_current);
} else
if(strcmp(s,"-m")==0){
	  group_mark(-1);
} else
if(strcmp(s,"m2c")==0){
	  backup();
          group_regroup(group_marker, group_current);
} else
if(strcmp(s,"z")==0){
          group_remove_empty();
          get_anything();
} else
if(strcmp(s,"fi")==0){
            int found;
	    found=group_find(cursor);
	    if(found!=-1)
	      {
		group_change_current(found, &group_current, group, vertex_used);
	      }
	    else
	      printf("CURSOR IS NOT INCIDENT TO ANY GROUP\n");
            get_anything();
} else
if(context==context_et0 && strcmp(s,"mv")==0){
	  float mv[3];
          vector_sub(cursor, et0_marker, mv);
	  backup();
          group_move(group_current, mv, group, vertex, vertex_used);
} else
if(strcmp(s,"de")==0){
	  backup();
          group_delete_edges(group_current);
} else
if(strcmp(s,"dt")==0){
	  backup();
          group_delete_triangles(group_current);
} else
if(strcmp(s,"det")==0){
	  backup();
          group_delete_triangles(group_current);
          group_delete_edges(group_current);
} else
if(strcmp(s,"pe")==0){
	  backup();
          group_paint_edges(group_current, current_color);
} else
if(strcmp(s,"pt")==0){
	  backup();
          group_paint_triangles(group_current, current_color);
} else
if(strcmp(s,"cp")==0){
	  backup();
          group_copy(False, False);
} else
if(strcmp(s,"cpe")==0){
	  backup();
          group_copy(True, False);
} else
if(strcmp(s,"cpt")==0){
	  backup();
          group_copy(False, True);
} else
if(strcmp(s,"cpet")==0){
	  backup();
          group_copy(True, True);
}

}
Exemplo n.º 10
0
static inline void task_sigchild(gid_t pgid, FAR _TCB *ctcb, int status)
{
  FAR struct task_group_s *chgrp = ctcb->group;
  FAR struct task_group_s *pgrp;
  siginfo_t info;

  DEBUGASSERT(chgrp);

  /* Get the parent task group.  It is possible that all of the members of
   * the parent task group have exited.  This would not be an error.  In 
   * this case, the child task group has been orphaned.
   */

  pgrp = group_find(chgrp->tg_pgid);
  if (!pgrp)
    {
      /* Set the task group ID to an invalid group ID.  The dead parent
       * task group ID could get reused some time in the future.
       */

      chgrp->tg_pgid = INVALID_GROUP_ID;
      return;
    }

  /* Save the exit status now if this is the main thread of the task group
   * that is exiting. Only the exiting main task of a task group carries
   * interpretable exit  Check if this is the main task that is exiting.
   */

  if ((ctcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_TASK)
    {
      task_exitstatus(pgrp, status);
    }

  /* But only the final exiting thread in a task group, whatever it is,
   * should generate SIGCHLD.
   */

  if (chgrp->tg_nmembers == 1)
    {
      /* Mark that all of the threads in the task group have exited */

      task_groupexit(pgrp);

      /* Create the siginfo structure.  We don't actually know the cause.
       * That is a bug. Let's just say that the child task just exit-ted
       * for now.
       */

      info.si_signo           = SIGCHLD;
      info.si_code            = CLD_EXITED;
      info.si_value.sival_ptr = NULL;
      info.si_pid             = ctcb->pid;
      info.si_status          = status;

      /* Send the signal.  We need to use this internal interface so that we
       * can provide the correct si_code value with the signal.
       */

      (void)group_signal(pgrp, &info);
    }
}
Exemplo n.º 11
0
static int group_register (const char *project_name, const char *framework_name,
                           const char *component_name, const char *description)
{
    ocoms_mca_base_var_group_t *group;
    int group_id, parent_id = -1;
    int ret;

    if (NULL == project_name && NULL == framework_name && NULL == component_name) {
        /* don't create a group with no name (maybe we should create a generic group?) */
        return -1;
    }

    /* XXX -- remove this once the project name is available in the component structure */
    if (framework_name || component_name) {
        project_name = NULL;
    }

    group_id = group_find (project_name, framework_name, component_name, true);
    if (0 <= group_id) {
        (void) ocoms_mca_base_var_group_get_internal (group_id, &group, true);
        group->group_isvalid = true;
        ocoms_mca_base_var_groups_timestamp++;

        /* group already exists. return it's index */
        return group_id;
    }

    group = OBJ_NEW(ocoms_mca_base_var_group_t);

    group->group_isvalid = true;

    if (NULL != project_name) {
        group->group_project = strdup (project_name);
        if (NULL == group->group_project) {
            OBJ_RELEASE(group);
            return OCOMS_ERR_OUT_OF_RESOURCE;
        }
    }
    if (NULL != framework_name) {
        group->group_framework = strdup (framework_name);
        if (NULL == group->group_framework) {
            OBJ_RELEASE(group);
            return OCOMS_ERR_OUT_OF_RESOURCE;
        }
    }
    if (NULL != component_name) {
        group->group_component = strdup (component_name);
        if (NULL == group->group_component) {
            OBJ_RELEASE(group);
            return OCOMS_ERR_OUT_OF_RESOURCE;
        }
    }
    if (NULL != description) {
        group->group_description = strdup (description);
        if (NULL == group->group_description) {
            OBJ_RELEASE(group);
            return OCOMS_ERR_OUT_OF_RESOURCE;
        }
    }

    if (NULL != framework_name && NULL != component_name) {
        if (component_name) {
            parent_id = group_register (project_name, framework_name, NULL, NULL);
        } else if (framework_name && project_name) {
            parent_id = group_register (project_name, NULL, NULL, NULL);
        }
    }

    /* avoid groups of the form ocoms_ocoms, ompi_ompi, etc */
    if (NULL != project_name && NULL != framework_name &&
        (0 == strcmp (project_name, framework_name))) {
        project_name = NULL;
    }

    /* build the group name */
    ret = ocoms_mca_base_var_generate_full_name4 (NULL, project_name, framework_name, component_name,
                                            &group->group_full_name);
    if (OCOMS_SUCCESS != ret) {
        OBJ_RELEASE(group);
        return ret;
    }

    group_id = ocoms_pointer_array_add (&ocoms_mca_base_var_groups, group);
    if (0 > group_id) {
        OBJ_RELEASE(group);
        return OCOMS_ERROR;
    }

    ocoms_hash_table_set_value_ptr (&ocoms_mca_base_var_group_index_hash, group->group_full_name,
                                   strlen (group->group_full_name), (void *)(uintptr_t) group_id);

    ocoms_mca_base_var_group_count++;
    ocoms_mca_base_var_groups_timestamp++;

    if (0 <= parent_id) {
        ocoms_mca_base_var_group_t *parent_group;

        (void) ocoms_mca_base_var_group_get_internal(parent_id, &parent_group, false);
        ocoms_value_array_append_item (&parent_group->group_subgroups, &group_id);
    }

    return group_id;
}