Exemple #1
0
static void printFileInfo(const char * name,
			  rpm_loff_t size, unsigned short mode,
			  unsigned int mtime,
			  unsigned short rdev, unsigned int nlink,
			  const char * owner, const char * group,
			  const char * linkto)
{
    char sizefield[21];
    char ownerfield[8+1], groupfield[8+1];
    char timefield[100];
    time_t when = mtime;  /* important if sizeof(int32_t) ! sizeof(time_t) */
    struct tm * tm;
    static time_t now;
    char * perms = rpmPermsString(mode);
    char *link = NULL;

    /* On first call, grab snapshot of now */
    if (now == 0)
	now = time(NULL);

    rstrlcpy(ownerfield, owner, sizeof(ownerfield));
    rstrlcpy(groupfield, group, sizeof(groupfield));

    /* this is normally right */
    snprintf(sizefield, sizeof(sizefield), "%20" PRIu64, size);

    /* this knows too much about dev_t */

    if (S_ISLNK(mode)) {
	rasprintf(&link, "%s -> %s", name, linkto);
    } else if (S_ISCHR(mode)) {
	perms[0] = 'c';
	snprintf(sizefield, sizeof(sizefield), "%3u, %3u", ((unsigned)(rdev >> 8) & 0xff),
			((unsigned)rdev & 0xff));
    } else if (S_ISBLK(mode)) {
Exemple #2
0
/**
 * Format file permissions for display.
 * @param td		tag data container
 * @return		formatted string
 */
static char * permsFormat(rpmtd td)
{
    char * val = NULL;

    if (rpmtdClass(td) != RPM_NUMERIC_CLASS) {
	val = xstrdup(_("(not a number)"));
    } else {
	val = rpmPermsString(rpmtdGetNumber(td));
    }

    return val;
}
Exemple #3
0
static void printStat(rpmtget tget)
{
    struct stat * st = &tget->sb;
    size_t nt = 100;
    char * t = alloca(nt);
    time_t when = st->st_mtime;
    struct tm * tm = localtime(&when);
    size_t nb = strftime(t, nt, "%F %T", tm);
    const char * perms = rpmPermsString(st->st_mode);

    t[nb] = '\0';
    /* XXX Note st->st_blocks to convert to linux "ls -island" spew. */
    fprintf(stderr, "%u %u %s %u %u %u %u %s %s",
	(unsigned) st->st_ino, (unsigned)st->st_blocks/2,
	perms, (unsigned)st->st_nlink,
	(unsigned)st->st_uid, (unsigned)st->st_gid,
	(unsigned)st->st_size, t, tget->uri);
    fprintf(stderr, "\n");
    perms = _free(perms);
}