---
name: "pmaRewriteMeta"
section: "3"
platform: "linux"
package: "pcp"
version: "7.2.2-2"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/pmaRewriteMeta"
---

# pmaRewriteMeta(3)

try to change the version of an archive metadata record

## NAME

**pmaRewriteMeta** - try to change the version of an archive metadata record

## C SYNOPSIS

**#include \<pcp/pmapi.h\>**\
 **#include \<pcp/libpcp.h\>**\
 **#include \<pcp/archive.h\>**

**int pmaRewriteMeta(\_\_pmLogCtl \****inlcp***,** **\_\_pmLogCtl \****outlcp***,** **\_\_int32\_t \****rbuf***);**

**cc ... -lpcp\_archive -lpcp**

## CAVEAT

This documentation is intended for internal Performance Co-Pilot (PCP) developer use.

These interfaces are not part of the PCP APIs that are guaranteed to remain fixed across releases, and they may not work, or may provide different semantics at some point in the future.

## DESCRIPTION

A physical metadata record from the input archive identified by *inlcp* is passed in via *rbuf* and this is reformatted if required to produce the equivalent metadata record for the output archive identified by *outlcp*.

Combined with the input and output archive versions, the type of the metadata record (as extracted from *rbuf*) is used to decide if; for some record types and version changes no rewriting is required.

**pmaRewriteMeta** is intended to be used in cases where the archive version of *inlcp* and *outlcp* are different. The only sane choice of archive versions today is **PM\_LOG\_VERS02** for *inlcp* and **PM\_LOG\_VERS03** for *outlcp*, which would be requesting a rewrite from archive version 2 format to archive version 3 format (as only versions 2 and 3 are currently supported).

If rewriting takes place the old *rbuf* will have been free'd and a new *rbuf* allocated with [**malloc**(3)](/malloc/3.md). It is the caller's responsibility to make sure this potential free-and-allocate will be safe, e.g. no dangling references into the contents of *rbuf*, or pass in a copy of the record if it is precious.

## DIAGNOSTICS AND RETURN VALUES

In several places, fatal errors will trigger an error message and force the application to exit.

If there is no defined translation for the versions of *inlcp* and *outlcp* then **pmaRewriteMeta** returns **PM\_ERR\_APPVERSION** (a slight perversion of this error code).

If no rewrite is performed, the return value is 0, otherwise a return value of 1 indicates a rewrite has taken place and *rbuf* has been reallocated.

## SEE ALSO

[**free**(3)](/free/3.md), [**malloc**(3)](/malloc/3.md), [**PMAPI**(3)](/PMAPI/3.md), and [**pmaRewriteData**(3)](/pmaRewriteData/3.md).
