[Previous] [Contents] [Next]

Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

pm_create()

Create an entry in the project manager namespace

Synopsis:

#include <sys/pm.h>
#include <sys/stat.h>

int pm_create(const char *name, 
              mode_t mode); 

Arguments:

name
Name of the entry to be created
mode
Type and access permissions associated with the entry.

Library:

libpm

Description:

The pm_create() creates a new entry in the power manager namespace. The mode specifies the file type and access permissions of the new object:

PM_NODE_NEXUS indicates the object is a non-leaf node (directory-like) object that can have further objects created below it in the name space.

If PM_NODE_NEXUS is not specified, the object is a leaf node and cannot have objects created below it in the namespace.

The access permissions are specified as for open() or creat(). See "Access Permissions" in the documentation for stat().

Returns:

0
Success.
-1
An error has occurred (errno is set).

Errors:

ENOENT
There's no power manager running.
EINVAL
Name begins with a '/' character
ENOTDIR
A component of name is not a directory
EACCES
Search permission is denied in a component of name.
EACCES
Write permission is denied in the last directory component of name
EEXIST
An object with name already exists.

Examples:

#include <sys/pm.h>
#include <stat.h>
#include <stdlib.h>
int
main()
{
   // create a directory node with rwxrwxr-x permissions
   if (pm_create("dir", PM_NODE_NEXUS|S_IRWXU|S_RWXG|S_IROTH|S_IXOTH) == -1) {
   perror("pm_create");
   return EXIT_FAILURE;
   }

   // create a node under "dir" with rw-rx-r-- permissions
   if (pm_create("dir/obj", S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH) == -1) {
      perror("pm_create");
      return EXIT_FAILURE;
    }
   return EXIT_SUCCESS;
}

Classification:

Neutrino

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

pm_attach(), stat()


[Previous] [Contents] [Next]