mkelem

Creates a file or directory element

Applicability

Product

Command type

ClearCase®

cleartool subcommand

ClearCase Remote Client

rcleartool subcommand

Platform

UNIX

Linux

Windows

Synopsis

  • ClearCase:
    mkelem [ -elt/ype element-type-name ] [ -nco | -ci [ -pti/me ] ]
    [ -mkp/ath ] [ -srfm ] [-master ] [ -nwa/rn ] [ -rolemap rolemap-selector ]

    [ -restore ] [ -c/omment comment | -cq/uery | -cqe/ach | -nc/omment ] element-pname ...

  • ClearCase Remote Client:
    mkelem [ -elt/ype element-type-name ] [ -nco | -ci ] [ -mkp/ath ]

    [ -c/omment comment | -cq/uery | -cqe/ach | -nc/omment ] element-pname ...

Description

The mkelem command creates one or more new elements. A new element can be created in a directory only if that directory element is checked out. mkelem appends an appropriate line to the directory's checkout comment.

If evil twin detection is enabled and the creation of a new element that is an evil twin of an existing element is attempted, an error is returned and the element is not created.

mkelem processes each element as follows:

  1. Determines an element type from the specified -eltype option or by performing file-typing.
  2. Creates an element object with that element type in the appropriate VOB database.
  3. Protects the element according to whether or not -rolemap has been specified:
    • If you specified mkelem -rolemap, ACL authorization is in effect for the new element; by default, its protections are inherited from the rolemap of the containing directory.
    • Otherwise, non-ACL authorization is in effect. On UNIX and Linux systems, if you are using the -ci option to convert a view-private file to an element, uses the permissions of that file including setuid and/or setgid bits; otherwise, sets the mode of the new element to 444 (for a file element) or 777 (for a directory element), as modified by your current umask(1) setting.
  4. Initializes the element's version tree by creating a single branch (named main), and a single, empty version (version 0) on that branch
  5. Does one of the following:
    • By default, checks out the element to your view.
      Note: At this point, other views see an empty file when they look at the element.
    • With the -nco option, does nothing.
    • With the -ci option, creates version 1 by copying a view-private file or an uploaded view-private file.
  6. Assigns the element to the same source storage pool, cleartext storage pool, and (for new directory elements) derived object storage pool as its parent directory element.
  7. In a snapshot view, updates the newly created element.
Note: Error messages appear if your config spec lacks a /main/LATEST rule. The mkelem command succeeds in creating version /main/0. However, because your view does not have a rule to select this version, you cannot see or check out the element.

Group selection of objects

For VOBs at feature level 8, group selection algorithms differ from those in effect for VOBs at feature level 7 or lower.

Feature level 7: group selection of new elements or symbolic links

On UNIX and Linux systems, setting the environment variable CLEARCASE_MKELEM_USE_GRPLIST to true enables the primary group intersection algorithm (the algorithm is always in effect for Windows systems).

Each operating system process has a process primary group and a process group list and each VOB has a VOB primary group and a VOB supplemental group list. We refer to the former collectively as the process groups and the latter as the VOB groups.
  • If the process primary group matches any VOB group, then that group becomes the new element's group; else
  • If the intersection of all process groups and all VOB groups yields exactly one group, then that group becomes the new element's group; else
  • Element creation fails.
When CLEARCASE_MKELEM_USE_GRPLIST is unset, an attempt is made to create the element in the process primary group.
Note: You can use the UNIX or Linux operating system command newgrp to set the primary group.

Group selection of derived objects (dynamic views)

In a dynamic view, the process that is creating a new file or directory uses its primary group as the group of the new object. Therefore, to create derived objects during an audited build, the account's primary group must be one of the VOB's groups.

Group selection in replicated VOBs

In a VOB family at feature level 8, replicas that do not preserve identities use the following algorithm to select the element's group during the replay of a mkelem oplog: if the importing replica is non-preserving, the new element or symbolic link is assigned the same group ownership as the initial containing directory element. Identity-preserving replicas also use this new algorithm during import at FL8 when the originating replica does not preserve identities.

At feature level 7 or lower, a non-identity preserving replica uses the VOB primary group during the import of an element- or symlink-creation oplog; an identity-preserving replica uses the VOB primary group if the originating replica is not identity-preserving.

At all feature levels, new elements and symlinks created in identity-preserving replicas are replayed in other identity-preserving replicas using the group assigned during creation at the originating replica.

Branch mastership acquisition in the Cadence Design Systems integration

In the case of the CDS Virtuoso integration running in a replicated environment, mkelem executes a synchronous request for mastership (SRFM) of an unmastered branch by default. The gdmco reference page describes this behavior in detail.

Restrictions

ACL authorization

If ACLs are enabled, the principal must have the following permissions:
  • read-info on VOB object
  • read-info on directory element
  • mod-checkout on directory element
  • mkelem on VOB

Non-ACL authorization

You must be a member of a group in the VOB's group list.

  • On UNIX or Linux, your primary group must be in the VOB's group list.
  • On Windows, your primary group or another group to which you belong must be in the VOB's group list. If your primary group is not in the VOB's group list, then there must be exactly one group in your group list that is also in the VOB's group list. Otherwise, you cannot create an element in the VOB.

Locks

An error occurs if one or more of these objects are locked: VOB, element type, pool (nondirectory elements).

Mastership

(Replicated VOBs) No mastership restrictions.

Options and arguments

Specifying the element type

Default
mkelem performs file-typing to select an element type. If file-typing fails, an error occurs. For details on file-typing, see the cc.magic reference page.
-elt/ype element-type-name
Specifies the type of element to be created. The element type must be a predefined type, or a user-defined type created with the mkeltype command. The element type must exist in each VOB in which you are creating a new element or (if element-type-selector is a global type) in the administrative VOB hierarchy associated with each VOB. Specifying -eltype directory is equivalent to using the mkdir command.

Checkout of the new element

Default
cleartool: mkelem checks out the new element. If a view-private file already exists at that pathname, it becomes the checked-out version of the element. Otherwise, an empty view-private file is created and becomes the checked-out version.
rcleartool: mkelem checks in the new element.
-nco
Suppresses checkout; mkelem creates the new element, along with the main branch and version \main\0, but does not check it out. If element-pname exists, it is moved aside to a .keep file, as explained earlier.
-ci [ -pti/me ]
Creates the new element and version /main/0, performs a checkout, and checks in a new version containing the data in view-private file or DO element-pname, which must exist. You cannot use this option when creating a directory element.

With -ptime, mkelem preserves the modification time of the file being checked in. If you omit this option, the modification time of the new version is set to the checkin time.

On some UNIX and Linux platforms, it is important that the modification time be preserved for archive files (libraries) created by ar(1) (and perhaps updated with ranlib(1)). The link editor, ld(1), generates an error message if the modification time does not match a time recorded in the archive itself. Be sure to use this option, or (more reliably) store archive files as elements of a user-defined type, created with the mkeltype -ptime command. This causes -ptime to be invoked when the element is checked in.

View-private parent directory of the new element

-mkp/ath
This option enables you to create an element within its view-private parent directory. In doing so, this option recursively creates elements from the view-private directories that are found in the specified pathname.
Note: For cleartool, you must run the command from a versioned directory that is the parent of the highest-level view-private directory. For example, to create the element foo.c that resides in the view private directory .../dir2, which in turn resides in the versioned directory .../dir1, you must run mkelem -mkpath from .../dir1:

cmd-context mkelem -nc -mkpath dir2/foo.c

The default checkout status of the newly created elements differs according to the command interface that you use:

  • If you use the cleartool subcommand, the element and the directory elements in its pathname are checked out.
  • If you use the rcleartool subcommand, the same set of elements are checked in.

Mastership and synchronous requests for mastership (replicated VOBs)

Default
  • ClearCase: assigns mastership of the element's main branch to the VOB replica that masters the main branch type.
  • ClearCase integration with Cadence Design Systems Virtuoso:
    • -srfm is invoked by default. See the gdmco reference page for details about this option.
    • -master is invoked by default. To change the default behavior, set the environment variable CCASE_CDS_MASTER to FALSE (or false). If CCASE_CDS_MASTER is set to FALSE, you can still specify -master to override its value.
-srfm
Issues a request for branch mastership synchronously with the checkout operation (unless -nco is specified, this command checks out the element).
-master
Assigns mastership of the main branch of the element to the VOB replica in which you execute the mkelem command. If your config spec includes -mkbranch lines or mkbranch rules that apply to the element, and you do not use the -nco option, mkelem creates these branches and assigns their mastership to the current VOB replica. mkelem also prints a note that these branches are explicitly mastered by the current replica; the output also displays the master replica of each associated branch type.

Display of warning messages

Default
Warning messages are displayed.
-nwa/rn
Suppresses warning messages.

ACL protection

Default
If the VOB is at feature level 8 or higher, the rolemap of the parent directory.
-rolemap rolemap-selector
If the VOB is at feature level 8 or higher, specifies the rolemap that is to protect the element. File mode bits are applied as in the case of VOBs at feature level 7 or lower. A rolemap does not require that ACLs be enforced.

Naming of pathnames when mkelem fails (dynamic views only)

Default
When mkelem fails in a dynamic view, element-pname is renamed element-pname.mkelem.
-restore
Restores element-pname.mkelem to its original name: element-pname. The mkelem command can fail in some circumstances; for example,
  • The VOB is protected against the creation of evil twins and the element to be created would be an evil twin
  • Element creation is prevented by a trigger

Event records and comments

Default
Creates one or more event records, with commenting controlled by your .clearcase_profile file (default: -cqe). See the comments reference page. Comments can be edited with chevent.
-c/omment comment | -cfi/le comment-file-pname |-cq/uery | -cqe/ach | -nc/omment
Overrides the default with the option you specify. See the comments reference page.

Specifying the elements

Default
None.
element-pname ...
The pathnames of one or more elements to be created. If you also specify the -ci option, each element-pname must name an existing view-private object. You cannot create a directory element with the same name as an existing view-private file or directory unless you specify -mkpath.

Examples

The UNIX system and Linux examples in this section are written for use in csh. If you use another shell, you might need to use different quoting and escaping conventions.

The Windows examples that include wildcards or quoting are written for use in cleartool interactive mode. If you use cleartool single-command mode, you might need to change the wildcards and quoting to make your command interpreter process the command appropriately.

In cleartool single-command mode, cmd-context represents the UNIX system and Linux shells or Windows command interpreter prompt, followed by the cleartool command. In cleartool interactive mode, cmd-context represents the interactive cleartool prompt.

  • Create a file element named rotate.c of type compressed_text_file, and check out the initial version (version 0).

    cmd-context  mkelem -nc -eltype compressed_text_file rotate.c
    Created element "rotate.c" (type "compressed_text_file").
    Checked out "rotate.c" from version "/main/0".

  • Create three file elements, cm_add.c, cm_fill.c, and msg.c, allowing the file-typing mechanism to determine the element types. Do not check out the initial versions.

    cmd-context  mkelem -nc -nco cm_add.c cm_fill.c msg.c
    Created element "cm_add.c" (type "text_file").
    Created element "cm_fill.c" (type "text_file").
    Created element "msg.c" (type "text_file").

  • Convert a view-private file named test_cmd.c to an element, and check in the initial version.

    cmd-context  mkelem -nc -ci test_cmd.c
    Created element "test_cmd.c" (type "text_file").
    Checked in "test_cmd.c" version "\main\1".

  • Create two directory elements and check out the initial version of each.

    cmd-context  mkelem -nc -eltype directory libs include
    Created element "libs" (type "directory").
    Checked out "libs" from version "/main/0".
    Created element "include" (type "directory").
    Checked out "include" from version "/main/0".

  • Create an element type named lib for library files, with the predefined binary_delta_file as its supertype. Then, change to the libs directory, check it out, and create two elements of type lib without checking them out.

    cmd-context  mkeltype -nc -supertype binary_delta_file lib
    Created element type "lib".
    cmd-context  cd libs
    cmd-context  co -nc .
    Checked out "." from version "\main\1".
    cmd-context  mkelem -nc -nco -eltype lib libntx.lib libpvt.lib
    Created element "libntx.lib" (type "lib").
    Created element "libpvt.lib" (type "lib").