2020-06-15 14:18:57 +00:00
|
|
|
|
/*-*- mode:c;indent-tabs-mode:nil;c-basic-offset:2;tab-width:8;coding:utf-8 -*-│
|
|
|
|
|
│vi: set net ft=c ts=2 sts=2 sw=2 fenc=utf-8 :vi│
|
|
|
|
|
╞══════════════════════════════════════════════════════════════════════════════╡
|
|
|
|
|
│ Copyright 2020 Justine Alexandra Roberts Tunney │
|
|
|
|
|
│ │
|
2020-12-28 01:18:44 +00:00
|
|
|
|
│ Permission to use, copy, modify, and/or distribute this software for │
|
|
|
|
|
│ any purpose with or without fee is hereby granted, provided that the │
|
|
|
|
|
│ above copyright notice and this permission notice appear in all copies. │
|
2020-06-15 14:18:57 +00:00
|
|
|
|
│ │
|
2020-12-28 01:18:44 +00:00
|
|
|
|
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
|
|
|
|
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
|
|
|
|
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
|
|
|
|
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
|
|
|
|
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
|
|
|
|
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
|
|
|
|
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
|
|
|
|
│ PERFORMANCE OF THIS SOFTWARE. │
|
2020-06-15 14:18:57 +00:00
|
|
|
|
╚─────────────────────────────────────────────────────────────────────────────*/
|
2023-08-16 22:53:06 +00:00
|
|
|
|
#include "libc/calls/struct/stat.h"
|
2023-08-12 06:14:02 +00:00
|
|
|
|
#include "libc/runtime/zipos.internal.h"
|
2023-08-16 01:24:53 +00:00
|
|
|
|
#include "libc/sysv/errfuns.h"
|
2020-06-15 14:18:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reads file metadata from αcτµαlly pδrταblε εxεcµταblε object store.
|
|
|
|
|
*
|
2023-08-17 03:11:19 +00:00
|
|
|
|
* @param name is obtained via __zipos_parseuri()
|
2020-06-15 14:18:57 +00:00
|
|
|
|
* @asyncsignalsafe
|
|
|
|
|
*/
|
2023-08-16 01:24:53 +00:00
|
|
|
|
int __zipos_stat(struct ZiposUri *name, struct stat *st) {
|
2023-10-03 14:27:25 +00:00
|
|
|
|
int cf;
|
2020-08-25 11:23:25 +00:00
|
|
|
|
struct Zipos *zipos;
|
2023-08-16 01:24:53 +00:00
|
|
|
|
if (!(zipos = __zipos_get())) return enoexec();
|
2023-08-17 03:11:19 +00:00
|
|
|
|
if ((cf = __zipos_find(zipos, name)) == -1) return -1;
|
2023-08-16 22:53:06 +00:00
|
|
|
|
if (__zipos_stat_impl(zipos, cf, st)) return -1;
|
|
|
|
|
st->st_ino = __zipos_inode(zipos, cf, name->path, name->len);
|
|
|
|
|
return 0;
|
2020-06-15 14:18:57 +00:00
|
|
|
|
}
|