It's expected that for each invasive change or important bugfix you will
include a test to your patch.
- Compile tests & run basic tests:
+ Compile binaries, libs, extra test programs and run the basic tests:
$ make check
+ Compile extra test programs only:
+
+ $ make check-programs
+
Note that the configure option --disable-static disables many of libmount and
libblkid unit tests.
Run all tests including tests that require root permissions:
# cd tests
- # ./run.sh [--verbose] [--memcheck]
+ # ./run.sh [options, see --help]
Alternatively using sudo and make:
- $ make check TS_COMMAND="true"
+ $ make check-programs
$ sudo -E make check TS_OPTS="--parallel=1"
note that as root you have to manually remove output and diff directories
Run subset of tests:
+ $ cd tests
$ ./run.sh <test_directory-name>
for example:
$ ./run.sh blkid
$ ./run.sh libmount
+ or individual test script, for example:
+
+ $ ./ts/cal/year
+
The tests is possible to exclude by ./run.sh --exclude=<list> where the
<list> is blank separated test names in format "testdir/testname", for example:
static void seek_track_head(int ctrl, struct format_descr *descr)
{
- lseek(ctrl, (descr->track * param.head + descr->head) * param.sect * SECTOR_SIZE, SEEK_SET);
+ lseek(ctrl, ((off_t) descr->track * param.head + descr->head)
+ * param.sect * SECTOR_SIZE, SEEK_SET);
}
static void format_disk(int ctrl, unsigned int track_from, unsigned int track_to)
buffer = xmalloc(ctl->pagesize);
while (current_page < ctl->npages) {
ssize_t rc;
+ off_t offset = (off_t) current_page * ctl->pagesize;
- if (do_seek && lseek(ctl->fd, current_page * ctl->pagesize, SEEK_SET) !=
- current_page * ctl->pagesize)
+ if (do_seek && lseek(ctl->fd, offset, SEEK_SET) != offset)
errx(EXIT_FAILURE, _("seek failed in check_blocks"));
rc = read(ctl->fd, buffer, ctl->pagesize);
.I command
.SH DESCRIPTION
.B sfdisk
-is a script-oriented tool for partitioning any block device.
+is a script-oriented tool for partitioning any block device. It
+runs in interactive mode if executed on terminal (stdin refers to a terminal).
Since version 2.26
.B sfdisk
}
return c ? c : -1;
}
- if (ret > 0)
- tries = 0;
+ tries = 0;
count -= ret;
buf += ret;
c += ret;
-#ifndef UTIL_LINUX_PT_SUN_H
-#define UTIL_LINUX_PT_SUN_H
+#ifndef UTIL_LINUX_PT_SGI_H
+#define UTIL_LINUX_PT_SGI_H
#include <stdint.h>
return sum;
}
-#endif /* UTIL_LINUX_PT_SUN_H */
+#endif /* UTIL_LINUX_PT_SGI_H */
#include <pwd.h>
extern struct passwd *xgetpwnam(const char *username, char **pwdbuf);
+extern struct passwd *xgetpwuid(uid_t uid, char **pwdbuf);
extern char *xgetlogin(void);
#endif /* UTIL_LINUX_PWDUTILS_H */
return NULL;
}
+struct passwd *xgetpwuid(uid_t uid, char **pwdbuf)
+{
+ struct passwd *pwd = NULL, *res = NULL;
+ int rc;
+
+ if (!pwdbuf)
+ return NULL;
+
+ *pwdbuf = xmalloc(UL_GETPW_BUFSIZ);
+ pwd = xcalloc(1, sizeof(struct passwd));
+
+ errno = 0;
+ rc = getpwuid_r(uid, pwd, *pwdbuf, UL_GETPW_BUFSIZ, &res);
+ if (rc != 0) {
+ errno = rc;
+ goto failed;
+ }
+ if (!res) {
+ errno = EINVAL;
+ goto failed;
+ }
+ return pwd;
+failed:
+ free(pwd);
+ free(*pwdbuf);
+ return NULL;
+}
+
char *xgetlogin(void)
{
struct passwd *pw = NULL;
pr->flags |= BLKID_FL_PRIVATE_FD;
return pr;
err:
- if (fd >= 0)
- close(fd);
+ close(fd);
blkid_free_probe(pr);
return NULL;
}
d->d_ntracks = ask_uint32(cxt, d->d_ntracks, _("tracks/cylinder"));
d->d_ncylinders = ask_uint32(cxt, d->d_ncylinders ,_("cylinders"));
#endif
- if (fdisk_ask_number(cxt, 1, d->d_nsectors * d->d_ntracks,
- d->d_nsectors * d->d_ntracks,
+ if (fdisk_ask_number(cxt, 1,
+ (uintmax_t) d->d_nsectors * d->d_ntracks,
+ (uintmax_t) d->d_nsectors * d->d_ntracks,
_("sectors/cylinder"), &res) == 0)
d->d_secpercyl = res;
return -ERANGE;
}
- *sz = nents * esz;
+ *sz = (size_t) nents * esz;
return 0;
}
/**
* fdisk_reset_iter:
* @itr: iterator pointer
- * @direction: FDISK_INTER_{FOR,BACK}WARD or -1 to keep the direction unchanged
+ * @direction: FDISK_ITER_{FOR,BACK}WARD or -1 to keep the direction unchanged
*
* Resets the iterator.
*/
*/
FILE *mnt_get_procfs_memstream(int fd, char **membuf)
{
- FILE *memf;
size_t sz = 0;
off_t cur;
+ *membuf = NULL;
+
/* in case of error, rewind to the original position */
cur = lseek(fd, 0, SEEK_CUR);
- if (read_procfs_file(fd, membuf, &sz) == 0
- && sz > 0
- && (memf = fmemopen(*membuf, sz, "r")))
- return memf;
+ if (read_procfs_file(fd, membuf, &sz) == 0 && sz > 0) {
+ FILE *memf = fmemopen(*membuf, sz, "r");
+ if (memf)
+ return memf; /* success */
+
+ free(*membuf);
+ *membuf = NULL;
+ }
/* error */
- lseek(fd, cur, SEEK_SET);
+ if (cur != (off_t) -1)
+ lseek(fd, cur, SEEK_SET);
return NULL;
}
#else
* DAMAGE.
* %End-Header%
*/
+#ifndef _UUID_UUID_PRIVATE_H
+#define _UUID_UUID_PRIVATE_H
#include <inttypes.h>
#include <sys/types.h>
*/
void uuid_pack(const struct uuid *uu, uuid_t ptr);
void uuid_unpack(const uuid_t in, struct uuid *uu);
+
+#endif /* _UUID_UUID_PRIVATE_H */
* there is no warranty.
*
*/
+#ifndef UTIL_LINUX_LOGIN_AUTH_H
+#define UTIL_LINUX_LOGIN_AUTH_H
#include <sys/types.h>
extern int auth_pam(const char *service_name, uid_t uid, const char *username);
+
+#endif /* UTIL_LINUX_LOGIN_AUTH_H */
#include "islocal.h"
#include "nls.h"
#include "pathnames.h"
+#include "pwdutils.h"
#include "setpwnam.h"
#include "strutils.h"
#include "xalloc.h"
int main(int argc, char **argv)
{
- char *oldshell;
+ char *oldshell, *pwbuf;
int nullshell = 0;
const uid_t uid = getuid();
struct sinfo info = { NULL };
parse_argv(argc, argv, &info);
if (!info.username) {
- pw = getpwuid(uid);
+ pw = xgetpwuid(uid, &pwbuf);
if (!pw)
errx(EXIT_FAILURE, _("you (user %d) don't exist."),
uid);
} else {
- pw = getpwnam(info.username);
+ pw = xgetpwnam(info.username, &pwbuf);
if (!pw)
errx(EXIT_FAILURE, _("user \"%s\" does not exist."),
info.username);
+#ifndef UTIL_LINUX_LOGIN_ISLOCAL_H
+#define UTIL_LINUX_LOGIN_ISLOCAL_H
+
extern int is_local(const char *user);
+
+#endif /* UTIL_LINUX_LOGIN_ISLOCAL_H */
* there is no warranty.
*
*/
+#ifndef UTIL_LINUX_LOGIN_LIBUSER_H
+#define UTIL_LINUX_LOGIN_LIBUSER_H
#include <sys/types.h>
extern int set_value_libuser(const char *service_name, const char *username,
uid_t uid, const char *attr, const char *val);
+
+#endif /* UTIL_LINUX_LOGIN_LIBUSER_H */
rc = EXIT_SUCCESS;
done:
- if (fd >= 0)
- close(fd);
+ close(fd);
return rc;
}
+#ifndef UTIL_LINUX_TERM_TTYMSG_H
+#define UTIL_LINUX_TERM_TTYMSG_H
+
char *ttymsg(struct iovec *iov, size_t iovcnt, char *line, int tmout);
+#endif /* UTIL_LINUX_TERM_TTYMSG_H */
--- /dev/null
+CPU op-mode(s): 32-bit, 64-bit
+CPU(s): 2
+On-line CPU(s) list: 0,1
+Thread(s) per core: 1
+Core(s) per socket: 1
+Socket(s) per book: 1
+Book(s) per drawer: 1
+Drawer(s): 2
+NUMA node(s): 1
+Vendor ID: IBM/S390
+Machine type: 2964
+CPU dynamic MHz: 5000
+CPU static MHz: 5000
+BogoMIPS: 3033.00
+Hypervisor: KVM/Linux
+Hypervisor vendor: KVM
+Virtualization type: full
+Dispatching mode: horizontal
+L1d cache: 256 KiB
+L1i cache: 192 KiB
+L2d cache: 4 MiB
+L2i cache: 4 MiB
+L3 cache: 64 MiB
+L4 cache: 480 MiB
+NUMA node0 CPU(s): 0,1
+Vulnerability L1tf: Not affected
+Vulnerability Meltdown: Not affected
+Vulnerability Spec store bypass: Not affected
+Vulnerability Spectre v1: Mitigation; __user pointer sanitization
+Vulnerability Spectre v2: Mitigation; execute trampolines
+Flags: esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx
+
+# The following is the parsable format, which can be fed to other
+# programs. Each different item in every column has an unique ID
+# starting from zero.
+# CPU,Core,Socket,Node,,L1d,L1i,L2d,L2i
+0,0,0,0,,0,0,0,0
+1,1,1,0,,1,1,1,1
+
+# The following is the parsable format, which can be fed to other
+# programs. Each different item in every column has an unique ID
+# starting from zero.
+# CPU,Core,Socket,Node,,L1d,L1i,L2d,L2i
+0,0,0,0,,0,0,0,0
+1,1,1,0,,1,1,1,1
*
* @(#)hexdump.h 5.4 (Berkeley) 6/1/90
*/
+#ifndef UTIL_LINUX_HEXDUMP_H
+#define UTIL_LINUX_HEXDUMP_H
+
#include "c.h"
#include "list.h"
void conv_u(struct hexdump_pr *, u_char *);
int next(char **, struct hexdump *);
int parse_args(int, char **, struct hexdump *);
+
+#endif /* UTIL_LINUX_HEXDUMP_H */