---
name: "th_set_type"
section: "3"
platform: "linux"
package: "libtar"
version: "1.2.20-8"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/th_set_from_stat"
---

# th\_set\_type(3)

set fields of a tar file header

Part of [th\_set\_from\_stat(3)](/th_set_from_stat/3.md).

## NAME

th\_set\_from\_stat, th\_finish, th\_set\_type, th\_set\_path, th\_set\_link, th\_set\_device, th\_set\_user, th\_set\_group, th\_set\_mode, th\_set\_mtime, th\_set\_size - set fields of a tar file header

## SYNOPSIS

**#include \<libtar.h\>**

**void th\_set\_from\_stat(TAR \****t***, struct stat \****s***);**

**void th\_set\_type(TAR \****t***, mode\_t** *mode***);**

**void th\_set\_path(TAR \****t***, char \****pathname***);**

**void th\_set\_link(TAR \****t***, char \****linkname***);**

**void th\_set\_device(TAR \****t***, dev\_t** *device***);**

**void th\_set\_user(TAR \****t***, uid\_t** *uid***);**

**void th\_set\_group(TAR \****t***, gid\_t** *gid***);**

**void th\_set\_mode(TAR \****t***, mode\_t** *mode***);**

**void th\_set\_mtime(TAR \****t***, time\_t** *fmtime***);**

**void th\_set\_size(TAR \****t***, off\_t** *fsize***);**

**void th\_finish(TAR \****t***);**

## VERSION

This man page documents version 1.2 of **libtar**.

## DESCRIPTION

The **th\_set\_\***() functions each set an individual field of the current tar header associated with the *TAR* handle *t*.  The **th\_set\_user**() and **th\_set\_group**() functions set both the numeric user/group ID fields and the user/group name text fields. The other functions set only the field that they refer to.

The **th\_set\_from\_stat**() function uses the other **th\_set\_\***() functions to set all of the fields at once, based on the data passed to it in the argument *s*.

The **th\_finish**() function sets the appropriate constants for the magic and version fields.  It then calculates the header checksum and fills in the checksum field.

## SEE ALSO

[**lstat**(2)](/lstat/2.md)
