ARCHIVE_ENTRY_STAT(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

✨ archive_entry_stat(3) ✨

okay so bestie, this page comes from the Library Functions Manual and it's literally the whole girlboss toolkit for the accessor functions that manipulate archive entry descriptions. πŸŽ€ no cap, there's like a million of them. let's go. πŸ’…


πŸ’– NAME πŸ’–

archive_entry_stat, archive_entry_copy_stat, archive_entry_filetype, archive_entry_set_filetype, archive_entry_mode, archive_entry_set_mode, archive_entry_size, archive_entry_size_is_set, archive_entry_set_size, archive_entry_unset_size, archive_entry_dev, archive_entry_set_dev, archive_entry_dev_is_set, archive_entry_devmajor, archive_entry_set_devmajor, archive_entry_devminor, archive_entry_set_devminor, archive_entry_ino, archive_entry_set_ino, archive_entry_ino_is_set, archive_entry_ino64, archive_entry_set_ino64, archive_entry_nlink, archive_entry_rdev, archive_entry_set_rdev, archive_entry_rdevmajor, archive_entry_set_rdevmajor, archive_entry_rdevminor, archive_entry_set_rdevminor β€” accessor functions for manipulating archive entry descriptions ✨

πŸ“š LIBRARY πŸ“š

Streaming Archive Library (libarchive, -larchive) β€” she's streaming, obviously. πŸ’–

🫢 SYNOPSIS 🫢

#include <archive_entry.h>

const struct stat *
archive_entry_stat(struct archive_entry *a);

void
archive_entry_copy_stat(struct archive_entry *a, const struct stat *sb);

mode_t
archive_entry_filetype(struct archive_entry *a);

void
archive_entry_set_filetype(struct archive_entry *a, unsigned int type);

mode_t
archive_entry_mode(struct archive_entry *a);

void
archive_entry_set_mode(struct archive_entry *a, mode_t mode);

int64_t
archive_entry_size(struct archive_entry *a);

int
archive_entry_size_is_set(struct archive_entry *a);

void
archive_entry_set_size(struct archive_entry *a, int64_t size);

void
archive_entry_unset_size(struct archive_entry *a);

dev_t
archive_entry_dev(struct archive_entry *a);

void
archive_entry_set_dev(struct archive_entry *a, dev_t dev);

int
archive_entry_dev_is_set(struct archive_entry *a);

dev_t
archive_entry_devmajor(struct archive_entry *a);

void
archive_entry_set_devmajor(struct archive_entry *a, dev_t major);

dev_t
archive_entry_devminor(struct archive_entry *a);

void
archive_entry_set_devminor(struct archive_entry *a, dev_t minor);

ino_t
archive_entry_ino(struct archive_entry *a);

void
archive_entry_set_ino(struct archive_entry *a, unsigned long ino);

int
archive_entry_ino_is_set(struct archive_entry *a);

int64_t
archive_entry_ino64(struct archive_entry *a);

void
archive_entry_set_ino64(struct archive_entry *a, int64_t ino);

unsigned int
archive_entry_nlink(struct archive_entry *a);

void
archive_entry_set_nlink(struct archive_entry *a, unsigned int count);

dev_t
archive_entry_rdev(struct archive_entry *a);

dev_t
archive_entry_rdevmajor(struct archive_entry *a);

dev_t
archive_entry_rdevminor(struct archive_entry *a);

void
archive_entry_set_rdev(struct archive_entry *a, dev_t dev);

void
archive_entry_set_rdevmajor(struct archive_entry *a, dev_t major);

void
archive_entry_set_rdevminor(struct archive_entry *a, dev_t minor);

🌈 DESCRIPTION 🌈

πŸ¦‹ Copying to and from struct stat πŸ¦‹

okay so archive_entry_stat() is the translator of the group πŸ’« β€” it converts all the various fields stored in the archive entry into the format that stat(2) uses. and the plot twist? the return value stays valid until either archive_entry_clear() or archive_entry_free() gets called. it is not affected by calls to the set accessor functions, so like, she doesn't care what you do to the setters, she's living her own life. πŸ’…

right now it sets these values in struct stat: st_atime, st_ctime, st_dev, st_gid, st_ino, st_mode, st_mtime, st_nlink, st_rdev, st_size, st_uid. and on platforms that support it, st_birthtime plus high-precision information for time-related fields gets included too. the way she serves extra on some platforms? iconic. ✨

and then archive_entry_copy_stat() goes the other direction β€” it copies fields from the platform's struct stat. anything that struct stat doesn't provide just stays unchanged. no notes. 🫢

πŸ’œ General accessor functions πŸ’œ

archive_entry_filetype() and archive_entry_set_filetype() get and set the filetype respectively. the file type is one of these constants:

  • AE_IFREG β€” Regular file
  • AE_IFLNK β€” Symbolic link
  • AE_IFSOCK β€” Socket
  • AE_IFCHR β€” Character device
  • AE_IFBLK β€” Block device
  • AE_IFDIR β€” Directory
  • AE_IFIFO β€” Named pipe (fifo)
not all file types are supported by all platforms, bestie. and heads up β€” the constants used by stat(2) may have different numeric values from the corresponding constants listed above. πŸ’€ don't just assume they match.

archive_entry_mode() and archive_entry_set_mode() get/set a combination of file type and permissions, basically giving you the equivalent of st_mode. but here's the tea: the recommended move is to use archive_entry_filetype() and archive_entry_perm() for getting, and archive_entry_set_filetype() and archive_entry_set_perm() for setting. slay responsibly. πŸ‘‘

archive_entry_size() returns the file size if it has been set, and 0 otherwise. archive_entry_size_is_set() is how you query that status β€” it's the vibe check for whether a size even exists. archive_entry_set_size() and archive_entry_unset_size() set and unset the size, respectively.

the number of references (hardlinks) can be obtained by calling archive_entry_nlink() and set with archive_entry_set_nlink(). πŸ”₯

🌸 Identifying unique files 🌸

archive_entry_dev() and archive_entry_ino64() are the duo that archive_entry_linkify(3) uses to find hardlinks. the pair of device and inode is supposed to identify hardlinked files β€” that's their whole main character job. πŸ’–

the device major and minor number can be obtained independently using archive_entry_devmajor() and archive_entry_devminor(). and you can set the device either via archive_entry_set_dev() or by the combination of major and minor number using archive_entry_set_devmajor() and archive_entry_set_devminor().

the inode number can be obtained using archive_entry_ino(). ⚠️ but listen β€” this is a legacy interface that uses the platform ino_t, which may be very small. to set the inode number, archive_entry_set_ino64() is the preferred interface. choose the glow-up, not the dusty one. πŸ™ˆ

🧚 Accessor functions for block and character devices 🧚

block and character devices are characterised either using a device number or a pair of major and minor number. the combined device number can be obtained with archive_device_rdev() and set with archive_device_set_rdev(). the major and minor numbers are accessed by archive_device_rdevmajor(), archive_device_rdevminor(), archive_device_set_rdevmajor() and archive_device_set_rdevminor().

the process of splitting the combined device number into major and minor number β€” and the reverse process of combing them β€” differs between platforms. some archive formats use the combined form, while other formats use the split form. so like, it depends. πŸ¦‹


πŸ‘‘ SEE ALSO πŸ‘‘

stat(2), archive_entry_acl(3), archive_entry_perms(3), archive_entry_time(3), libarchive(3)


and that's the whole page, bestie!! πŸ’œ this one's from Debian and it's dated February 2, 2012 β€” so yes, she's an elder but she's still absolutely eating. πŸ“ ARCHIVE_ENTRY_STAT(3) out. periodt. πŸ’…βœ¨

πŸ“¦ where this page comes from