44 #include <sys/mkdev.h>
47 #ifdef MAJOR_IN_SYSMACROS
48 #include <sys/sysmacros.h>
56 #define major(dev) (((dev) >> 8) & 0xff)
57 #define minor(dev) ((dev)&0xff)
63 const char *errfmt = (
err == ELOOP) ?
"symbolic link in a loop" :
"broken symbolic link to `%s'";
65 const char *errfmt =
"broken symbolic link to `%s'";
67 if (ms->flags & RZ_MAGIC_ERROR) {
78 int mime = ms->flags & RZ_MAGIC_MIME;
91 if ((ms->flags & RZ_MAGIC_SYMLINK) == 0)
98 if (ms->flags & RZ_MAGIC_ERROR) {
103 fn, strerror(errno)) == -1)
109 if ((
sb->st_mode & S_IFMT) != S_IFREG) {
110 if ((
mime & RZ_MAGIC_MIME_TYPE) &&
111 file_printf(ms,
"application/x-not-regular-file") == -1)
117 if (
sb->st_mode & S_ISUID)
122 if (
sb->st_mode & S_ISGID)
127 if (
sb->st_mode & S_ISVTX)
133 switch (
sb->st_mode & S_IFMT) {
145 if ((ms->flags & RZ_MAGIC_DEVICES) != 0)
147 #ifdef HAVE_STAT_ST_RDEV
149 if (
file_printf(ms,
"character special (%d/%d/%d)",
150 major(
sb->st_rdev), dv_unit(
sb->st_rdev),
151 dv_subunit(
sb->st_rdev)) == -1)
171 if ((ms->flags & RZ_MAGIC_DEVICES) != 0)
173 #ifdef HAVE_STAT_ST_RDEV
176 major(
sb->st_rdev), dv_unit(
sb->st_rdev),
177 dv_subunit(
sb->st_rdev)) == -1)
193 if ((ms->flags & RZ_MAGIC_DEVICES) != 0)
206 if (ms->flags & RZ_MAGIC_ERROR) {
211 "unreadable symlink `%s' (%s)",
fn,
212 strerror(errno)) == -1)
224 char buf2[BUFSIZ + BUFSIZ + 4];
226 if (!(
tmp = strrchr(
fn,
'/'))) {
229 if (
tmp -
fn + 1 > BUFSIZ) {
230 if (ms->flags & RZ_MAGIC_ERROR) {
246 if ((ms->flags & RZ_MAGIC_SYMLINK) != 0) {
248 ms->flags &= RZ_MAGIC_SYMLINK;
250 ms->flags |= RZ_MAGIC_SYMLINK;
251 return p !=
NULL ? 1 : -1;
283 if ((ms->flags & RZ_MAGIC_DEVICES) == 0 &&
sb->st_size == 0) {
284 if ((!
mime || (
mime & RZ_MAGIC_MIME_TYPE)) &&
static static sync static getppid static getegid const char static filename char static len readlink
void file_error(struct rz_magic_set *, int, const char *,...)
int file_printf(struct rz_magic_set *, const char *,...)
checking print the parsed form of the magic use in n conjunction with m to debug a new magic file n before installing it n mime
int file_fsmagic(struct rz_magic_set *ms, const char *fn, struct stat *sb)
static int bad_link(RzMagic *ms, int err, char *buf)
static const char struct stat static buf struct stat static buf static idle const char static path static fd const char static len const void static prot const char struct module static image struct kernel_sym static table unsigned char static buf static fsuid unsigned struct dirent unsigned static count const struct iovec static count static pid const void static len static flags const struct sched_param static p static pid static policy struct timespec static tp static suid unsigned fn
RZ_API const char * rz_magic_file(RzMagic *ms, const char *inname)
static uint32_t const uint8_t * buf2
static int nch(struct parse *, cset *)