fs.c | fs.c | |||
---|---|---|---|---|
skipping to change at line 24 | skipping to change at line 24 | |||
/*@-usereleased -onlytrans@*/ | /*@-usereleased -onlytrans@*/ | |||
struct fsinfo { | struct fsinfo { | |||
/*@only@*/ /*@relnull@*/ | /*@only@*/ /*@relnull@*/ | |||
const char * mntPoint; /*!< path to mount point. */ | const char * mntPoint; /*!< path to mount point. */ | |||
dev_t dev; /*!< devno for mount point. */ | dev_t dev; /*!< devno for mount point. */ | |||
int rdonly; /*!< is mount point read only? */ | int rdonly; /*!< is mount point read only? */ | |||
}; | }; | |||
#ifdef __cplusplus | ||||
GENfree(rpmuint64_t *) | ||||
GENfree(struct fsinfo *) | ||||
#endif /* __cplusplus */ | ||||
/*@unchecked@*/ | /*@unchecked@*/ | |||
/*@only@*/ /*@null@*/ | /*@only@*/ /*@null@*/ | |||
static struct fsinfo * filesystems = NULL; | static struct fsinfo * filesystems = NULL; | |||
/*@unchecked@*/ | /*@unchecked@*/ | |||
/*@only@*/ /*@null@*/ | /*@only@*/ /*@null@*/ | |||
static const char ** fsnames = NULL; | static const char ** fsnames = NULL; | |||
/*@unchecked@*/ | /*@unchecked@*/ | |||
static int numFilesystems = 0; | static int numFilesystems = 0; | |||
void rpmFreeFilesystems(void) | void rpmFreeFilesystems(void) | |||
skipping to change at line 102 | skipping to change at line 107 | |||
buf = alloca(size); | buf = alloca(size); | |||
num = mntctl(MCTL_QUERY, size, buf); | num = mntctl(MCTL_QUERY, size, buf); | |||
if ( num <= 0 ) { | if ( num <= 0 ) { | |||
rpmlog(RPMLOG_ERR, _("mntctl() failed to return mount points: %s\n" ), | rpmlog(RPMLOG_ERR, _("mntctl() failed to return mount points: %s\n" ), | |||
strerror(errno)); | strerror(errno)); | |||
return 1; | return 1; | |||
} | } | |||
numFilesystems = num; | numFilesystems = num; | |||
filesystems = xcalloc((numFilesystems + 1), sizeof(*filesystems)); | filesystems = (struct fsinfo *) xcalloc((numFilesystems + 1), sizeof(*f | |||
fsnames = xcalloc((numFilesystems + 1), sizeof(char *)); | ilesystems)); | |||
fsnames = (const char **) xcalloc((numFilesystems + 1), sizeof(char *)) | ||||
; | ||||
for (vm = buf, i = 0; i < num; i++) { | for (vm = buf, i = 0; i < num; i++) { | |||
char *fsn; | char *fsn; | |||
fsnameLength = vm->vmt_data[VMT_STUB].vmt_size; | fsnameLength = vm->vmt_data[VMT_STUB].vmt_size; | |||
fsn = xmalloc(fsnameLength + 1); | fsn = (char *) xmalloc(fsnameLength + 1); | |||
strncpy(fsn, (char *)vm + vm->vmt_data[VMT_STUB].vmt_off, | strncpy(fsn, (char *)vm + vm->vmt_data[VMT_STUB].vmt_off, | |||
fsnameLength); | fsnameLength); | |||
filesystems[i].mntPoint = fsnames[i] = fsn; | filesystems[i].mntPoint = fsnames[i] = fsn; | |||
#if defined(RPM_VENDOR_OPENPKG) /* always-skip-proc-filesystem */ | #if defined(RPM_VENDOR_OPENPKG) /* always-skip-proc-filesystem */ | |||
if (!(strcmp(fsn, "/proc") == 0)) { | if (!(strcmp(fsn, "/proc") == 0)) { | |||
#endif | #endif | |||
if (Stat(fsn, &sb) < 0) { | if (Stat(fsn, &sb) < 0) { | |||
switch(errno) { | switch(errno) { | |||
skipping to change at line 196 | skipping to change at line 201 | |||
#else | #else | |||
struct statfs * mounts = NULL; | struct statfs * mounts = NULL; | |||
#endif | #endif | |||
int mntCount = 0, flags = MNT_NOWAIT; | int mntCount = 0, flags = MNT_NOWAIT; | |||
int nextMount = 0; | int nextMount = 0; | |||
/* XXX 0 on error, errno set */ | /* XXX 0 on error, errno set */ | |||
mntCount = getmntinfo(&mounts, flags); | mntCount = getmntinfo(&mounts, flags); | |||
# endif | # endif | |||
filesystems = xcalloc((numAlloced + 1), sizeof(*filesystems)); /* X XX memory leak */ | filesystems = (struct fsinfo *) xcalloc((numAlloced + 1), sizeof(*files ystems)); /* XXX memory leak */ | |||
numFilesystems = 0; | numFilesystems = 0; | |||
while (1) { | while (1) { | |||
# if GETMNTENT_ONE | # if GETMNTENT_ONE | |||
/* this is Linux */ | /* this is Linux */ | |||
/*@-modunconnomods -moduncon @*/ | /*@-modunconnomods -moduncon @*/ | |||
our_mntent * itemptr = getmntent(mtab); | our_mntent * itemptr = getmntent(mtab); | |||
if (!itemptr) break; | if (!itemptr) break; | |||
item = *itemptr; /* structure assignment */ | item = *itemptr; /* structure assignment */ | |||
mntdir = item.our_mntdir; | mntdir = item.our_mntdir; | |||
skipping to change at line 251 | skipping to change at line 256 | |||
case ENOENT: /* XXX avoid /proc if leaked into *BSD jails . */ | case ENOENT: /* XXX avoid /proc if leaked into *BSD jails . */ | |||
case EACCES: /* XXX fuse fs #220991 */ | case EACCES: /* XXX fuse fs #220991 */ | |||
case ESTALE: | case ESTALE: | |||
continue; | continue; | |||
/*@notreached@*/ /*@switchbreak@*/ break; | /*@notreached@*/ /*@switchbreak@*/ break; | |||
} | } | |||
} | } | |||
if ((numFilesystems + 2) == numAlloced) { | if ((numFilesystems + 2) == numAlloced) { | |||
numAlloced += 10; | numAlloced += 10; | |||
filesystems = xrealloc(filesystems, | filesystems = (struct fsinfo *) xrealloc(filesystems, | |||
sizeof(*filesystems) * (numAlloced + 1)); | sizeof(*filesystems) * (numAlloced + 1)); | |||
} | } | |||
filesystems[numFilesystems].dev = sb.st_dev; | filesystems[numFilesystems].dev = sb.st_dev; | |||
filesystems[numFilesystems].mntPoint = xstrdup(mntdir); | filesystems[numFilesystems].mntPoint = xstrdup(mntdir); | |||
filesystems[numFilesystems].rdonly = rdonly; | filesystems[numFilesystems].rdonly = rdonly; | |||
#if 0 | #if 0 | |||
rpmlog(RPMLOG_DEBUG, "%5d 0x%04x %s %s\n", | rpmlog(RPMLOG_DEBUG, "%5d 0x%04x %s %s\n", | |||
numFilesystems, | numFilesystems, | |||
(unsigned) filesystems[numFilesystems].dev, | (unsigned) filesystems[numFilesystems].dev, | |||
skipping to change at line 278 | skipping to change at line 283 | |||
# if GETMNTENT_ONE || GETMNTENT_TWO | # if GETMNTENT_ONE || GETMNTENT_TWO | |||
(void) fclose(mtab); | (void) fclose(mtab); | |||
# elif defined(HAVE_GETMNTINFO_R) | # elif defined(HAVE_GETMNTINFO_R) | |||
mounts = _free(mounts); | mounts = _free(mounts); | |||
# endif | # endif | |||
filesystems[numFilesystems].dev = 0; | filesystems[numFilesystems].dev = 0; | |||
filesystems[numFilesystems].mntPoint = NULL; | filesystems[numFilesystems].mntPoint = NULL; | |||
filesystems[numFilesystems].rdonly = 0; | filesystems[numFilesystems].rdonly = 0; | |||
fsnames = xcalloc((numFilesystems + 1), sizeof(*fsnames)); | fsnames = (const char **) xcalloc((numFilesystems + 1), sizeof(*fsnames )); | |||
for (i = 0; i < numFilesystems; i++) | for (i = 0; i < numFilesystems; i++) | |||
fsnames[i] = filesystems[i].mntPoint; | fsnames[i] = filesystems[i].mntPoint; | |||
fsnames[numFilesystems] = NULL; | fsnames[numFilesystems] = NULL; | |||
/*@-nullstate@*/ /* FIX: fsnames[] may be NULL */ | /*@-nullstate@*/ /* FIX: fsnames[] may be NULL */ | |||
return 0; | return 0; | |||
/*@=nullstate@*/ | /*@=nullstate@*/ | |||
} | } | |||
#endif /* HAVE_MNTCTL */ | #endif /* HAVE_MNTCTL */ | |||
skipping to change at line 322 | skipping to change at line 327 | |||
const char * sourceDir; | const char * sourceDir; | |||
int lastfs = 0; | int lastfs = 0; | |||
dev_t lastDev = (dev_t)-1; /* I hope nobody uses -1 for a st_de v */ | dev_t lastDev = (dev_t)-1; /* I hope nobody uses -1 for a st_de v */ | |||
struct stat sb; | struct stat sb; | |||
int rc = 1; /* assume failure */ | int rc = 1; /* assume failure */ | |||
if (!fsnames) | if (!fsnames) | |||
if (getFilesystemList()) | if (getFilesystemList()) | |||
return rc; | return rc; | |||
usages = xcalloc(numFilesystems, sizeof(*usages)); | usages = (rpmuint64_t *) xcalloc(numFilesystems, sizeof(*usages)); | |||
sourceDir = rpmGetPath("%{_sourcedir}", NULL); | sourceDir = rpmGetPath("%{_sourcedir}", NULL); | |||
maxLen = strlen(sourceDir); | maxLen = strlen(sourceDir); | |||
for (i = 0; i < numFiles; i++) { | for (i = 0; i < numFiles; i++) { | |||
len = strlen(fileList[i]); | len = strlen(fileList[i]); | |||
if (maxLen < len) maxLen = len; | if (maxLen < len) maxLen = len; | |||
} | } | |||
buf = alloca(maxLen + 1); | buf = (char *) alloca(maxLen + 1); | |||
lastDir = alloca(maxLen + 1); | lastDir = (char *) alloca(maxLen + 1); | |||
dirName = alloca(maxLen + 1); | dirName = (char *) alloca(maxLen + 1); | |||
*lastDir = '\0'; | *lastDir = '\0'; | |||
/* cut off last filename */ | /* cut off last filename */ | |||
for (i = 0; i < numFiles; i++) { | for (i = 0; i < numFiles; i++) { | |||
if (*fileList[i] == '/') { | if (*fileList[i] == '/') { | |||
strcpy(buf, fileList[i]); | strcpy(buf, fileList[i]); | |||
chptr = buf + strlen(buf) - 1; | chptr = buf + strlen(buf) - 1; | |||
while (*chptr != '/') chptr--; | while (*chptr != '/') chptr--; | |||
if (chptr == buf) | if (chptr == buf) | |||
buf[1] = '\0'; | buf[1] = '\0'; | |||
End of changes. 8 change blocks. | ||||
10 lines changed or deleted | 17 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |