TDB_OPEN(3)

πŸ“¦
version 1.4.15+samba4.24.7 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– TDB_OPEN πŸ’– (section 3, bestie, Linux Programmer's Manual energy)

okay so. this is the manual page for tdb_open, living in the Linux Programmer's Manual, section 3. it's giving "let me open a tdb database for u" ✨


🌸 NAME 🌸

tdb_open β€” open a tdb database. that's it. that's the whole job. slay. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

#include <tdb.h>

TDB_CONTEXT *tdb_open(const char *pathname, int hash_size,
        int tdb_flags, int open_flags, mode_t mode );

copy that exactly, bestie, character for character. no typos, no vibes-based retyping. πŸ’–


πŸ¦‹ DESCRIPTION πŸ¦‹

so tdb_open opens the database, and β€” plot twist β€” it creates it if necessary. main character behavior honestly. it does both. iconic.

the hash size is advisory, which is a fancy way of saying it's a suggestion, not a demand. use zero for a default value. zero = "idk u pick, i trust u". 🫢

tdb_flags can be one of these, and i need u to actually read them:

  • TDB_CLEAR_IF_FIRST β€” clear the database if we are the only one with it open. like wiping the whiteboard only when literally nobody else is in the room. ✨
  • TDB_INTERNAL β€” don't use a file, instead store the data in memory. the pathname, open_flags, and mode are ignored in this case. so if u pass them, they just… don't get used. no cap. this one is useful if you need a quick associative array or map. lowkey a whole cheat code. πŸ”₯
  • TDB_NOLOCK β€” don't do any locking. and heads up: this is always turned on for read-only file descriptors. so that's not even optional there, it's just the vibe. πŸ”’πŸš«
  • TDB_NOMMAP β€” don't use mmap. simple as that. no mmap. periodt.
  • TDB_CONVERT β€” create a database in the reverse of native endian. normally, when the database is created (or cleared with TDB_CLEAR_IF_FIRST), it is created in native endian order. this flag is set (or unset) automatically for existing databases. so it kind of handles itself for stuff that already exists. πŸ’«

and then: the open_flags and mode are passed straight to the open call on the database file. straight through, no detour, no filter.

⚠️ a flags value of O_WRONLY is invalid. do not do that. i'm begging. πŸ™ˆ

🌈 RETURN VALUE 🌈

on success, a pointer to an opaque data structure β€” a TDB_CONTEXT β€” is returned. yay, u got context. πŸ’–

on error, a NULL is returned. and that's it. that's the whole return value situation. check for NULL, bestie, i'm serious. 😭


πŸ‘‘ AUTHORS πŸ‘‘

  • Software: Andrew Tridgell <tridge@linuxcare.com> and Luke Kenneth Casson Leighton
  • Man page: Ben Woodard <ben@valinux.com>

legends, honestly. ate. πŸ’…


⭐ SEE ALSO ⭐

open(2), gdbm(3), tdb(3)

go read those too, iykyk. 🧚


and that's the page, bestie πŸŽ€ this one came from Samba, dated Aug 16, 2000, and yeah it's old enough to have its own throwback playlist but the info still hits. mwah. πŸ’œπŸŒΈ