Skip to content

Commit

Permalink
lfs fix from Filip
Browse files Browse the repository at this point in the history
  • Loading branch information
iMilnb committed Jun 16, 2013
1 parent 6b6f6d2 commit 4b5f598
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 29 deletions.
37 changes: 19 additions & 18 deletions fsops.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
*
*/

#include "pkgin.h"
#include <dirent.h>
#include <sys/statvfs.h>

#if _FILE_OFFSET_BITS == 32
#undef _FILE_OFFSET_BITS
#define _FILE_OFFSET_BITS 64 /* needed for large filesystems on sunos */
#endif
#include "pkgin.h"
#include <dirent.h>

/* Variable options for the repositories file */
static const struct VarParam {
Expand All @@ -52,8 +51,8 @@ static const struct VarParam {
int
fs_has_room(const char *dir, int64_t size)
{
int64_t freesize;
struct statvfs fsbuf;
int64_t freesize;
struct statvfs fsbuf;


if (statvfs(dir, &fsbuf) < 0)
Expand All @@ -70,7 +69,7 @@ fs_has_room(const char *dir, int64_t size)
uint64_t
fs_room(const char *dir)
{
struct statvfs fsbuf;
struct statvfs fsbuf;

if (statvfs(dir, &fsbuf) < 0)
err(EXIT_FAILURE, "Can't statvfs() `%s'", dir);
Expand All @@ -81,20 +80,22 @@ fs_room(const char *dir)
void
clean_cache()
{
DIR *dp;
DIR *dp;
struct dirent *ep;
char pkgpath[BUFSIZ];

if ((dp = opendir(pkgin_cache)) != NULL) {
while ((ep = readdir(dp)) != NULL)
if (ep->d_name[0] != '.') {
snprintf(pkgpath, BUFSIZ, "%s/%s", pkgin_cache, ep->d_name);
if (unlink(pkgpath) < 0)
err(EXIT_FAILURE, "could not delete %s", pkgpath);
}
closedir(dp);
} else
char pkgpath[BUFSIZ];

if ((dp = opendir(pkgin_cache)) == NULL)
err(EXIT_FAILURE, "couldn't open %s", pkgin_cache);

while ((ep = readdir(dp)) != NULL)
if (ep->d_name[0] != '.') {
snprintf(pkgpath, BUFSIZ, "%s/%s",
pkgin_cache, ep->d_name);
if (unlink(pkgpath) < 0)
err(EXIT_FAILURE,
"could not delete %s", pkgpath);
}
closedir(dp);
}

void
Expand Down
26 changes: 15 additions & 11 deletions pkglist.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* $Id: pkglist.c,v 1.11 2012/07/15 17:36:34 imilh Exp $ */

/*
* Copyright (c) 2009, 2010, 2011 The NetBSD Foundation, Inc.
* Copyright (c) 2009, 2010, 2011, 2012, 2013 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
Expand Down Expand Up @@ -34,7 +34,7 @@
#include <regex.h>

Plisthead r_plisthead, l_plisthead;
int r_plistcounter, l_plistcounter;
int r_plistcounter, l_plistcounter;

/**
* \fn malloc_pkglist
Expand Down Expand Up @@ -237,7 +237,7 @@ list_pkgs(const char *pkgquery, int lstype)
{
Pkglist *plist;
Plistnumbered *plisthead;
int rc;
int rc;
char pkgstatus, outpkg[BUFSIZ];

/* list installed packages + status */
Expand Down Expand Up @@ -266,7 +266,8 @@ list_pkgs(const char *pkgquery, int lstype)
if (pkgstatus != '\0') {
snprintf(outpkg, BUFSIZ, "%s %c",
plist->full, pkgstatus);
printf("%-20s %s\n", outpkg, plist->comment);
printf("%-20s %s\n", outpkg,
plist->comment);
}

}
Expand All @@ -293,15 +294,15 @@ search_pkg(const char *pattern)
{
Pkglist *plist;
regex_t re;
int rc;
int rc;
char eb[64], is_inst, outpkg[BUFSIZ];
int matched_pkgs;
int matched_pkgs;

matched_pkgs = 0;

if (!SLIST_EMPTY(&r_plisthead)) {
if ((rc = regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE))
!= 0) {
if ((rc = regcomp(&re, pattern,
REG_EXTENDED|REG_NOSUB|REG_ICASE)) != 0) {
regerror(rc, &re, eb, sizeof(eb));
errx(1, "regcomp: %s: %s", pattern, eb);
}
Expand All @@ -310,12 +311,14 @@ search_pkg(const char *pattern)
is_inst = '\0';

if (regexec(&re, plist->name, 0, NULL, 0) == 0 ||
regexec(&re, plist->comment, 0, NULL, 0) == 0) {
regexec(&re, plist->comment,
0, NULL, 0) == 0) {

matched_pkgs = 1;

if (!SLIST_EMPTY(&l_plisthead)) {
rc = pkg_is_installed(&l_plisthead, plist);
rc = pkg_is_installed(&l_plisthead,
plist);

if (rc == 0)
is_inst = PKG_EQUAL;
Expand All @@ -326,7 +329,8 @@ search_pkg(const char *pattern)

}

snprintf(outpkg, BUFSIZ, "%s %c", plist->full, is_inst);
snprintf(outpkg, BUFSIZ, "%s %c",
plist->full, is_inst);

printf("%-20s %s\n", outpkg, plist->comment);
}
Expand Down

0 comments on commit 4b5f598

Please sign in to comment.