lock

Locks an object

APPLICABILITY

ClearCase (cleartool subcommand), Attache (command)

SYNOPSIS

lock [ -rep·lace ] [ -nus·ers login-name[,...] | -obs·olete ]

[ -c·omment comment | -cfi·le comment-file-pname |-cq·uery | -cqe·ach | -nc·omment ]
{ [ -pna·me ] pname ...
| object-selector ...
}

DESCRIPTION

The lock command creates a lock on an entire VOB, or on one or more file-system objects, type objects, or VOB storage pools. A lock on an object disables operations that modify the object; a lock has no effect on read operations, such as lshistory. (Exception: see the Storage Pool Lock: Cleartext Pool section.)

The VOB does not need to be mounted for you to lock type objects, storage pools, or the VOB itself. However, you need a view context (and therefore a mounted VOB if you're using a dynamic view) to lock elements or versions.

The following sections describe the several kinds of locks.

VOB Lock

Locking an entire VOB disables all write operations to that VOB and forces a database checkpoint by causing a state flush. A typical application is locking a VOB to prevent it from being modified during backup.

You must lock a VOB before backing it up, and you cannot use the -nusers option. With -nusers, it is possible that the VOB will be modified during the backup, and the nuser lock does not perform a database checkpoint.

NOTE: Locking a VOB does not lock its cleartext storage pools, because this would prevent read access to text_file, compressed_text_file, and binary_delta_file elements. (For example, it would prevent a locked VOB from being backed up.) To completely lock a VOB, you must also lock its cleartext pools, using one or more lock pool: commands. You may want to do this to move a cleartext pool.

Type Lock

In general, locking a type object disables these kinds of operations:

The following sections describe how these general rules apply to the different kinds of type objects.

Storage Pool Lock

Locking a VOB storage pool inhibits commands that create or remove the pool's data containers. It also prevents the pool's scrubbing parameters from being modified with mkpool -update. The following sections describe how this principle applies to the different kinds of storage pools.

LOCKING OR UNLOCKING GLOBAL TYPES

Locking or unlocking a global type or one of its local copies locks or unlocks the global type and all local copies. For more information, see Administering ClearCase.

OBSOLETE OBJECTS

An object becomes obsolete if it is processed with a lock -obsolete command. An obsolete type object or obsolete storage pool is not only locked, but is also invisible to certain forms of the lstype, lslock, lspool, and lsvtree commands. An obsolete VOB or obsolete VOB object is no different from one with an ordinary lock. You can change an object's status from obsolete to locked by using a lock -replace command:

cmd-context lock -obsolete brtype:test_branch (make a branch type obsolete)

Locked branch type "test_branch".

cmd-context lock -replace brtype:test_branch (change the branch type to 'just locked')

Similarly, you can use a lock -replace command to make a locked object obsolete.

REMOVING LOCKS

The unlock command removes a lock from an object, reenabling the previously prohibited operations.

PERMISSIONS AND LOCKS

Kind of Object

Users Permitted to Lock the Object

Type object

Type owner, VOB owner, member of the ClearCase group

Storage pool

VOB owner, member of the ClearCase group

VOB

VOB owner, member of the ClearCase group

Element

Element owner, VOB owner, member of the ClearCase group

Branch

Branch creator, element owner, VOB owner, member of the ClearCase group

ClearGuide object (activity, checkpoint, domain, role, state, user)

Object owner, VOB owner, member of the ClearCase group

See the permissions reference page.

Locks: The command fails if the VOB containing the object is locked.

MULTISITE MASTERSHIP

(Replicated VOBs only) A lock -obsolete command fails if the local replica does not master the object. However, a regular lock command succeeds even if the local replica does not have mastership. (Regular locks are not replicated and obsolete locks are.)

OPTIONS AND ARGUMENTS

REPLACING AN EXISTING LOCK.  Default: An error occurs if you attempt to lock an object that is already locked.

-rep·lace

(Cannot be used when locking an entire VOB) Uses a single atomic transaction to replace an existing lock with a new lock. (If you use two commands to unlock the object and then lock it again, there is a short interval during which the object is unprotected.)

You can use this option to change a object's status from just locked to obsolete.

SPECIFYING THE DEGREE OF LOCKING.  Default: Locks an object to all users, but does not make the object obsolete.

-nus·ers login-name [,...]

Allows the specified users to continue using the object, which becomes locked to all other users. The list of user names must be comma-separated, with no white space.
-obs·olete

Locks an object for all users, and also makes it obsolete.

EVENT RECORDS AND COMMENTS. Default: Creates one or more event records, with commenting controlled by your .clearcase_profile file (default: -nc). See CUSTOMIZING COMMENT HANDLING in 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 OBJECTS TO BE LOCKED.  Default: The final arguments are assumed to be the names of elements and/or branches. To lock another kind of object, you must use an object-selector prefix.

When locking type objects and storage pools, the command processes objects in the VOB containing the current working directory. To lock an entire VOB, you must specify a VOB.

[ -pna·me ] pname ...
object-selector ... (mutually exclusive)

One or more names, specifying the objects to be locked. To lock an element, you can specify the element itself (for example, foo.c@@) or any of its versions (for example, foo.c or foo.c@@\RLS1.3).To lock a branch, use an extended pathname (for example, foo.c@@\main\rel2_bugfix). If pname has the form of an object selector, you must use the -pname option to indicate that pname is a pathname.
Specify object-selector in one of the following forms:

vob-selector

vob:pname-in-vob

pname-in-vob can be the pathname of the VOB-tag (whether or not the VOB is mounted) or of any file-system object within the VOB (if the VOB is mounted). It cannot be the pathname of the VOB storage directory.

attribute-type-selector

attype:type-name[@vob-selector]

branch-type-selector

brtype:type-name[@vob-selector]

element-type-selector

eltype:type-name[@vob-selector]

hyperlink-type-selector

hltype:type-name[@vob-selector]

label-type-selector

lbtype:type-name[@vob-selector]

trigger-type-selector

trtype:type-name[@vob-selector]

pool-selector

pool:pool-name[@vob-selector]

oid-obj-selector

oid:object-oid[@vob-selector]

EXAMPLES

Examples including wildcards or quoting are written for use in cleartool interactive mode. If you use cleartool single-command mode, you may 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 command interpreter prompt. In cleartool interactive mode, cmd-context represents the interactive cleartool prompt. In Attache, cmd-context represents the workspace prompt.

cmd-context lock lbtype:REL1 lbtype:REL1.1 lbtype:REL2
Locked label type "REL1".
Locked label type "REL1.1".
Locked label type "REL2".
cmd-context lock -obsolete brtype:rel2_bugfix
Locked branch type "rel2_bugfix".
cmd-context lock vob:.
Locked versioned object base "\users_hw".
cmd-context lock -nusers gomez,jackson brtype:test
Locked branch type "test".
cmd-context lock *.c
Locked file element "hello.c".
Locked file element "msg.c".
Locked file element "util.c".
cmd-context checkout -nc msg.c
cleartool: Error: Lock on file element prevents operation "checkout".
cleartool: Error: Unable to check out "msg.c".

SEE ALSO

unlock



Feedback on the documentation in this site? We welcome any comments!
Copyright © 1999 by Rational Software Corporation. All rights reserved.