Compare commits

..
1 Commits
Author SHA1 Message Date
Denis Vlasenko a7887ebc8c fdisk: revert assidentally applied post-1.6.0 patch 2007-06-02 13:05:29 +00:00
13 changed files with 141 additions and 129 deletions

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
VERSION = 1
PATCHLEVEL = 6
SUBLEVEL = 2
SUBLEVEL = 0
EXTRAVERSION =
NAME = Unnamed
+1 -1
View File
@@ -1550,7 +1550,7 @@ static void configure_package(deb_file_t *deb_file)
/* Run the postinst script */
if (run_package_script(package_name, "postinst") != 0) {
/* TODO: handle failure gracefully */
bb_error_msg_and_die("postinst failure.. set status to what?");
bb_error_msg_and_die("postrm failure.. set status to what?");
}
/* Change status to reflect success */
set_status(status_num, "install", 1);
+7 -1
View File
@@ -32,10 +32,16 @@
#define DATE_OPT_TIMESPEC 0x20
#define DATE_OPT_HINT 0x40
static void xputenv(char *s)
{
if (putenv(s) != 0)
bb_error_msg_and_die(bb_msg_memory_exhausted);
}
static void maybe_set_utc(int opt)
{
if (opt & DATE_OPT_UTC)
putenv((char*)"TZ=UTC0");
xputenv((char*)"TZ=UTC0");
}
int date_main(int argc, char **argv);
+3 -3
View File
@@ -33,9 +33,7 @@ int bb_echo(char **argv)
eflag = '\\',
nflag = 1, /* 1 -- print '\n' */
};
arg = *++argv;
if (!arg)
goto newline_ret;
++argv;
#else
const char *p;
char nflag = 1;
@@ -109,7 +107,9 @@ int bb_echo(char **argv)
putchar(' ');
}
#if ENABLE_FEATURE_FANCY_ECHO
newline_ret:
#endif
if (nflag) {
putchar('\n');
}
+16 -24
View File
@@ -182,23 +182,19 @@ static void initialize_group_array(void);
int bb_test(int argc, char **argv)
{
int res;
char *arg0;
bool _off;
arg0 = strrchr(argv[0], '/');
if (!arg0++) arg0 = argv[0];
if (arg0[0] == '[') {
if (LONE_CHAR(argv[0], '[')) {
--argc;
if (!arg0[1]) { /* "[" ? */
if (NOT_LONE_CHAR(argv[argc], ']')) {
bb_error_msg("missing ]");
return 2;
}
} else { /* assuming "[[" */
if (strcmp(argv[argc], "]]") != 0) {
bb_error_msg("missing ]]");
return 2;
}
if (NOT_LONE_CHAR(argv[argc], ']')) {
bb_error_msg("missing ]");
return 2;
}
argv[argc] = NULL;
} else if (strcmp(argv[0], "[[") == 0) {
--argc;
if (strcmp(argv[argc], "]]")) {
bb_error_msg("missing ]]");
return 2;
}
argv[argc] = NULL;
}
@@ -223,19 +219,15 @@ int bb_test(int argc, char **argv)
if (argc == 2)
return *argv[1] == '\0';
//assert(argc);
/* remember if we saw argc==4 which wants *no* '!' test */
_off = argc - 4;
if (_off ?
(LONE_CHAR(argv[1], '!'))
: (argv[1][0] != '!' || argv[1][1] != '\0'))
{
if (LONE_CHAR(argv[1], '!')) {
bool _off;
if (argc == 3)
return *argv[2] != '\0';
_off = argc - 4;
t_lex(argv[2 + _off]);
if (t_wp_op && t_wp_op->op_type == BINOP) {
t_wp = &argv[1 + _off];
return binop() == _off;
return binop() == 0;
}
}
t_wp = &argv[1];
@@ -386,7 +378,7 @@ static int binop(void)
static int filstat(char *nm, enum token mode)
{
struct stat s;
int i = i; /* gcc 3.x thinks it can be used uninitialized */
int i;
if (mode == FILSYM) {
#ifdef S_IFLNK
+16 -16
View File
@@ -48,11 +48,11 @@ enum {
OPTBIT_L,
OPTBIT_o,
OPTBIT_r,
USE_FEATURE_GREP_CONTEXT( OPTBIT_A ,)
USE_FEATURE_GREP_CONTEXT( OPTBIT_B ,)
USE_FEATURE_GREP_CONTEXT( OPTBIT_C ,)
USE_FEATURE_GREP_EGREP_ALIAS(OPTBIT_E ,)
USE_DESKTOP( OPTBIT_w ,)
USE_FEATURE_GREP_CONTEXT(OPTBIT_A ,)
USE_FEATURE_GREP_CONTEXT(OPTBIT_B ,)
USE_FEATURE_GREP_CONTEXT(OPTBIT_C ,)
USE_FEATURE_GREP_CONTEXT(OPTBIT_E ,)
USE_DESKTOP( OPTBIT_w ,)
OPT_l = 1 << OPTBIT_l,
OPT_n = 1 << OPTBIT_n,
OPT_q = 1 << OPTBIT_q,
@@ -68,19 +68,19 @@ enum {
OPT_L = 1 << OPTBIT_L,
OPT_o = 1 << OPTBIT_o,
OPT_r = 1 << OPTBIT_r,
OPT_A = USE_FEATURE_GREP_CONTEXT( (1 << OPTBIT_A)) + 0,
OPT_B = USE_FEATURE_GREP_CONTEXT( (1 << OPTBIT_B)) + 0,
OPT_C = USE_FEATURE_GREP_CONTEXT( (1 << OPTBIT_C)) + 0,
OPT_E = USE_FEATURE_GREP_EGREP_ALIAS((1 << OPTBIT_E)) + 0,
OPT_w = USE_DESKTOP( (1 << OPTBIT_w)) + 0,
OPT_A = USE_FEATURE_GREP_CONTEXT((1 << OPTBIT_A)) + 0,
OPT_B = USE_FEATURE_GREP_CONTEXT((1 << OPTBIT_B)) + 0,
OPT_C = USE_FEATURE_GREP_CONTEXT((1 << OPTBIT_C)) + 0,
OPT_E = USE_FEATURE_GREP_CONTEXT((1 << OPTBIT_E)) + 0,
OPT_w = USE_DESKTOP( (1 << OPTBIT_w)) + 0,
};
#define PRINT_FILES_WITH_MATCHES (option_mask32 & OPT_l)
#define PRINT_LINE_NUM (option_mask32 & OPT_n)
#define BE_QUIET (option_mask32 & OPT_q)
#define SUPPRESS_ERR_MSGS (option_mask32 & OPT_s)
#define PRINT_MATCH_COUNTS (option_mask32 & OPT_c)
#define FGREP_FLAG (option_mask32 & OPT_F)
#define PRINT_FILES_WITH_MATCHES (option_mask32 & OPT_l)
#define PRINT_LINE_NUM (option_mask32 & OPT_n)
#define BE_QUIET (option_mask32 & OPT_q)
#define SUPPRESS_ERR_MSGS (option_mask32 & OPT_s)
#define PRINT_MATCH_COUNTS (option_mask32 & OPT_c)
#define FGREP_FLAG (option_mask32 & OPT_F)
#define PRINT_FILES_WITHOUT_MATCHES (option_mask32 & OPT_L)
typedef unsigned char byte_t;
-3
View File
@@ -277,9 +277,6 @@ static void console_init(void)
while (fd > 2) close(fd--);
}
messageD(L_LOG, "console='%s'", s);
} else {
/* Make sure fd 0,1,2 are not closed */
bb_sanitize_stdio();
}
s = getenv("TERM");
+3 -8
View File
@@ -31,10 +31,9 @@
#include "libbb.h"
/* Ask the user for a password.
* Return 1 if the user gives the correct password for entry PW,
* 0 if not. Return 1 without asking if PW has an empty password.
*
* NULL pw means "just fake it for login with bad username" */
Return 1 if the user gives the correct password for entry PW,
0 if not. Return 1 without asking for a password if run by UID 0
or if PW has an empty password. */
int correct_password(const struct passwd *pw)
{
@@ -47,9 +46,6 @@ int correct_password(const struct passwd *pw)
char buffer[256];
#endif
correct = "aa"; /* fake salt. crypt() can choke otherwise */
if (!pw)
goto fake_it; /* "aa" will never match */
correct = pw->pw_passwd;
#if ENABLE_FEATURE_SHADOWPASSWDS
if (LONE_CHAR(pw->pw_passwd, 'x') || LONE_CHAR(pw->pw_passwd, '*')) {
@@ -63,7 +59,6 @@ int correct_password(const struct passwd *pw)
if (!correct || correct[0] == '\0')
return 1;
fake_it:
unencrypted = bb_askpass(0, "Password: ");
if (!unencrypted) {
return 0;
+5 -5
View File
@@ -109,9 +109,8 @@ static int adduser(struct passwd *p)
if (putpwent(p, file) == -1) {
bb_perror_nomsg_and_die();
}
/* Do fclose even if !ENABLE_FEATURE_CLEAN_UP.
* We will exec passwd, files must be flushed & closed before that! */
fclose(file);
if (ENABLE_FEATURE_CLEAN_UP)
fclose(file);
#if ENABLE_FEATURE_SHADOWPASSWDS
/* add to shadow if necessary */
@@ -124,7 +123,8 @@ static int adduser(struct passwd *p)
0, /* sp->sp_min */
99999, /* sp->sp_max */
7); /* sp->sp_warn */
fclose(file);
if (ENABLE_FEATURE_CLEAN_UP)
fclose(file);
}
#endif
@@ -134,7 +134,7 @@ static int adduser(struct passwd *p)
if (addgroup) addgroup_wrapper(p);
/* Clear the umask for this process so it doesn't
* screw up the permissions on the mkdir and chown. */
* * screw up the permissions on the mkdir and chown. */
umask(0);
if (!(option_mask32 & OPT_DONT_MAKE_HOME)) {
/* Set the owner and group so it is owned by the new user,
+4 -3
View File
@@ -276,8 +276,8 @@ int login_main(int argc, char **argv)
pw = getpwnam(username);
if (!pw) {
strcpy(username, "UNKNOWN");
goto fake_it;
safe_strncpy(username, "UNKNOWN", sizeof(username));
goto auth_failed;
}
if (pw->pw_passwd[0] == '!' || pw->pw_passwd[0] == '*')
@@ -292,10 +292,11 @@ int login_main(int argc, char **argv)
/* Don't check the password if password entry is empty (!) */
if (!pw->pw_passwd[0])
break;
fake_it:
/* authorization takes place here */
if (correct_password(pw))
break;
auth_failed:
opt &= ~LOGIN_OPT_f;
bb_do_delay(FAIL_DELAY);
+2 -2
View File
@@ -267,11 +267,11 @@ int wget_main(int argc, char **argv)
#if ENABLE_FEATURE_WGET_AUTHENTICATION
if (target.user) {
fprintf(sfp, "Authorization: Basic %s\r\n",
base64enc((unsigned char*)target.user, buf, strlen(target.user)));
base64enc((unsigned char*)target.user, buf, sizeof(buf)));
}
if (use_proxy && server.user) {
fprintf(sfp, "Proxy-Authorization: Basic %s\r\n",
base64enc((unsigned char*)server.user, buf, strlen(server.user)));
base64enc((unsigned char*)server.user, buf, sizeof(buf)));
}
#endif
-4
View File
@@ -179,7 +179,6 @@ config HUSH
config HUSH_HELP
bool "help builtin"
default n
depends on HUSH
help
Enable help builtin in hush. Code size + ~1 kbyte.
@@ -207,21 +206,18 @@ config HUSH_JOB
config HUSH_TICK
bool "Process substitution"
default n
depends on HUSH
help
Enable process substitution `command` and $(command) in hush.
config HUSH_IF
bool "Support if/then/elif/else/fi"
default n
depends on HUSH
help
Enable if/then/elif/else/fi in hush.
config HUSH_LOOPS
bool "Support for, while and until loops"
default n
depends on HUSH
help
Enable for, while and until loops in hush.
+83 -58
View File
@@ -7,10 +7,6 @@
* Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
#ifndef _LARGEFILE64_SOURCE
/* For lseek64 */
#define _LARGEFILE64_SOURCE
#endif
#include <assert.h> /* assert */
#include "libbb.h"
@@ -38,9 +34,6 @@
#define LINUX_LVM 0x8e
#define LINUX_RAID 0xfd
/* Used for sector numbers. Today's disk sizes make it necessary */
typedef unsigned long long ullong;
struct hd_geometry {
unsigned char heads;
unsigned char sectors;
@@ -84,12 +77,10 @@ struct partition {
unsigned char size4[4]; /* nr of sectors in partition */
} ATTRIBUTE_PACKED;
static const char unable_to_open[] = "cannot open %s";
static const char unable_to_read[] = "cannot read from %s";
static const char unable_to_seek[] = "cannot seek on %s";
static const char unable_to_write[] = "cannot write to %s";
static const char ioctl_error[] = "BLKGETSIZE ioctl failed on %s";
static void fdisk_fatal(const char *why) ATTRIBUTE_NORETURN;
enum failure {
ioctl_error, unable_to_open, unable_to_read, unable_to_seek,
unable_to_write
};
enum label_type {
label_dos, label_sun, label_sgi, label_aix, label_osf
@@ -147,6 +138,7 @@ static void list_types(const char *const *sys);
static unsigned read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *mesg);
#endif
static const char *partition_type(unsigned char type);
static void fdisk_fatal(enum failure why) ATTRIBUTE_NORETURN;
static void get_geometry(void);
static int get_boot(enum action what);
@@ -167,7 +159,7 @@ static unsigned get_nr_sects(const struct partition *p);
struct pte {
struct partition *part_table; /* points into sectorbuffer */
struct partition *ext_pointer; /* points into sectorbuffer */
ullong offset; /* disk sector number */
off_t offset; /* disk sector number */
char *sectorbuffer; /* disk sector contents */
#if ENABLE_FEATURE_FDISK_WRITABLE
char changed; /* boolean */
@@ -612,41 +604,69 @@ get_nr_sects(const struct partition *p)
/* normally O_RDWR, -l option gives O_RDONLY */
static int type_open = O_RDWR;
static int ext_index; /* the prime extended partition */
static int listing; /* no aborts for fdisk -l */
static int listing; /* no aborts for fdisk -l */
static int dos_compatible_flag = ~0;
#if ENABLE_FEATURE_FDISK_WRITABLE
static int dos_changed;
static int nowarn; /* no warnings for fdisk -l/-s */
#endif
static unsigned user_cylinders, user_heads, user_sectors;
static unsigned pt_heads, pt_sectors;
static unsigned kern_heads, kern_sectors;
static ullong extended_offset; /* offset of link pointers */
static ullong total_number_of_sectors;
static off_t extended_offset; /* offset of link pointers */
static void fdisk_fatal(const char *why)
static unsigned long long total_number_of_sectors;
static void fdisk_fatal(enum failure why)
{
const char *message;
if (listing) {
close(fd);
longjmp(listingbuf, 1);
}
bb_error_msg_and_die(why, disk_device);
switch (why) {
case unable_to_open:
message = "cannot open %s";
break;
case unable_to_read:
message = "cannot read from %s";
break;
case unable_to_seek:
message = "cannot seek on %s";
break;
case unable_to_write:
message = "cannot write to %s";
break;
case ioctl_error:
message = "BLKGETSIZE ioctl failed on %s";
break;
default:
message = "fatal error";
}
bb_error_msg_and_die(message, disk_device);
}
static void
seek_sector(ullong secno)
seek_sector(off_t secno)
{
secno *= sector_size;
if (lseek64(fd, (off64_t)secno, SEEK_SET) == (off64_t) -1)
off_t offset = secno * sector_size;
if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
fdisk_fatal(unable_to_seek);
}
#if ENABLE_FEATURE_FDISK_WRITABLE
static void
write_sector(ullong secno, char *buf)
write_sector(off_t secno, char *buf)
{
seek_sector(secno);
if (write(fd, buf, sector_size) != sector_size)
@@ -656,7 +676,7 @@ write_sector(ullong secno, char *buf)
/* Allocate a buffer and read a partition table sector */
static void
read_pte(struct pte *pe, ullong offset)
read_pte(struct pte *pe, off_t offset)
{
pe->offset = offset;
pe->sectorbuffer = xmalloc(sector_size);
@@ -908,10 +928,10 @@ clear_partition(struct partition *p)
#if ENABLE_FEATURE_FDISK_WRITABLE
static void
set_partition(int i, int doext, ullong start, ullong stop, int sysid)
set_partition(int i, int doext, off_t start, off_t stop, int sysid)
{
struct partition *p;
ullong offset;
off_t offset;
if (doext) {
p = ptes[i].ext_pointer;
@@ -1162,7 +1182,7 @@ static void
get_geometry(void)
{
int sec_fac;
uint64_t v64;
unsigned long long bytes; /* really u64 */
get_sectorsize();
sec_fac = sector_size / 512;
@@ -1182,16 +1202,18 @@ get_geometry(void)
sectors = user_sectors ? user_sectors :
pt_sectors ? pt_sectors :
kern_sectors ? kern_sectors : 63;
if (ioctl(fd, BLKGETSIZE64, &v64) == 0) {
/* got bytes, convert to 512 byte sectors */
total_number_of_sectors = (v64 >> 9);
if (ioctl(fd, BLKGETSIZE64, &bytes) == 0) {
/* got bytes */
} else {
unsigned long longsectors; /* need temp of type long */
if (ioctl(fd, BLKGETSIZE, &longsectors))
longsectors = 0;
total_number_of_sectors = longsectors;
unsigned long longsectors;
if (ioctl(fd, BLKGETSIZE, &longsectors))
longsectors = 0;
bytes = ((unsigned long long) longsectors) << 9;
}
total_number_of_sectors = (bytes >> 9);
sector_offset = 1;
if (dos_compatible_flag)
sector_offset = sectors;
@@ -1425,10 +1447,10 @@ read_int(unsigned low, unsigned dflt, unsigned high, unsigned base, const char *
break;
}
if (absolute) {
ullong bytes;
unsigned long long bytes;
unsigned long unit;
bytes = (ullong) i * absolute;
bytes = (unsigned long long) i * absolute;
unit = sector_size * units_per_sector;
bytes += unit/2; /* round */
bytes /= unit;
@@ -1822,7 +1844,7 @@ wrong_p_order(int *prev)
{
const struct pte *pe;
const struct partition *p;
ullong last_p_start_pos = 0, p_start_pos;
off_t last_p_start_pos = 0, p_start_pos;
int i, last_i = 0;
for (i = 0 ; i < partitions; i++) {
@@ -1990,8 +2012,8 @@ list_table(int xtra)
for (i = 0; i < partitions; i++) {
const struct pte *pe = &ptes[i];
ullong psects;
ullong pblocks;
off_t psects;
off_t pblocks;
unsigned podd;
p = pe->part_table;
@@ -2013,10 +2035,10 @@ list_table(int xtra)
partname(disk_device, i+1, w+2),
!p->boot_ind ? ' ' : p->boot_ind == ACTIVE_FLAG /* boot flag */
? '*' : '?',
(ullong) cround(get_partition_start(pe)), /* start */
(ullong) cround(get_partition_start(pe) + psects /* end */
(unsigned long long) cround(get_partition_start(pe)), /* start */
(unsigned long long) cround(get_partition_start(pe) + psects /* end */
- (psects ? 1 : 0)),
(ullong) pblocks, podd ? '+' : ' ', /* odd flag on end */
(unsigned long long) pblocks, podd ? '+' : ' ', /* odd flag on end */
p->sys_ind, /* type id */
partition_type(p->sys_ind)); /* type name */
@@ -2063,7 +2085,7 @@ x_list_table(int extend)
#if ENABLE_FEATURE_FDISK_WRITABLE
static void
fill_bounds(ullong *first, ullong *last)
fill_bounds(off_t *first, off_t *last)
{
int i;
const struct pte *pe = &ptes[0];
@@ -2082,9 +2104,9 @@ fill_bounds(ullong *first, ullong *last)
}
static void
check(int n, unsigned h, unsigned s, unsigned c, ullong start)
check(int n, unsigned h, unsigned s, unsigned c, off_t start)
{
ullong total, real_s, real_c;
off_t total, real_s, real_c;
real_s = sector(s) - 1;
real_c = cylinder(s, c);
@@ -2098,11 +2120,11 @@ check(int n, unsigned h, unsigned s, unsigned c, ullong start)
printf("Partition %d: sector %d greater than "
"maximum %d\n", n, s, sectors);
if (real_c >= cylinders)
printf("Partition %d: cylinder %llu greater than "
printf("Partition %d: cylinder %"OFF_FMT"u greater than "
"maximum %d\n", n, real_c + 1, cylinders);
if (cylinders <= 1024 && start != total)
printf("Partition %d: previous sectors %llu disagrees with "
"total %llu\n", n, start, total);
printf("Partition %d: previous sectors %"OFF_FMT"u disagrees with "
"total %"OFF_FMT"u\n", n, start, total);
}
static void
@@ -2110,7 +2132,7 @@ verify(void)
{
int i, j;
unsigned total = 1;
ullong first[partitions], last[partitions];
off_t first[partitions], last[partitions];
struct partition *p;
if (warn_geometry())
@@ -2154,7 +2176,7 @@ verify(void)
if (extended_offset) {
struct pte *pex = &ptes[ext_index];
ullong e_last = get_start_sect(pex->part_table) +
off_t e_last = get_start_sect(pex->part_table) +
get_nr_sects(pex->part_table) - 1;
for (i = 4; i < partitions; i++) {
@@ -2188,9 +2210,9 @@ add_partition(int n, int sys)
int i, num_read = 0;
struct partition *p = ptes[n].part_table;
struct partition *q = ptes[ext_index].part_table;
ullong limit, temp;
ullong start, stop = 0;
ullong first[partitions], last[partitions];
long long llimit;
off_t start, stop = 0, limit, temp,
first[partitions], last[partitions];
if (p && p->sys_ind) {
printf(msg_part_already_defined, n + 1);
@@ -2200,9 +2222,12 @@ add_partition(int n, int sys)
if (n < 4) {
start = sector_offset;
if (display_in_cyl_units || !total_number_of_sectors)
limit = (ullong) heads * sectors * cylinders - 1;
llimit = heads * sectors * cylinders - 1;
else
limit = total_number_of_sectors - 1;
llimit = total_number_of_sectors - 1;
limit = llimit;
if (limit != llimit)
limit = 0x7fffffff;
if (extended_offset) {
first[ext_index] = extended_offset;
last[ext_index] = get_start_sect(q) +
@@ -2231,12 +2256,12 @@ add_partition(int n, int sys)
if (start > limit)
break;
if (start >= temp+units_per_sector && num_read) {
printf("Sector %lld is already allocated\n", temp);
printf("Sector %"OFF_FMT"d is already allocated\n", temp);
temp = start;
num_read = 0;
}
if (!num_read && start == temp) {
ullong saved_start;
off_t saved_start;
saved_start = start;
start = read_int(cround(saved_start), cround(saved_start), cround(limit),
@@ -2509,7 +2534,7 @@ move_begin(int i)
{
struct pte *pe = &ptes[i];
struct partition *p = pe->part_table;
ullong new, first;
off_t new, first;
if (warn_geometry())
return;