summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2010-09-11 20:43:48 +0200
committerSergei Golubchik <sergii@pisem.net>2010-09-11 20:43:48 +0200
commita3d80d952d7b99680ca4a3a89e128ecc0d490c10 (patch)
tree0d72ee69e037cdd09618ddb53652dd1b220890dc /mysys
parentec06ba24553d2d83b3a6a6bc4d8150910b01ee7c (diff)
parent966661c8cc75dd7d540a5fe40b4d893c40e91d26 (diff)
downloadmariadb-git-a3d80d952d7b99680ca4a3a89e128ecc0d490c10.tar.gz
merge with 5.1
Diffstat (limited to 'mysys')
-rw-r--r--mysys/Makefile.am4
-rw-r--r--mysys/errors.c4
-rw-r--r--mysys/mf_iocache.c11
-rw-r--r--mysys/mf_pack.c12
-rw-r--r--mysys/my_bitmap.c2
-rw-r--r--mysys/my_copy.c33
-rw-r--r--mysys/my_gethwaddr.c2
-rw-r--r--mysys/my_getopt.c13
-rw-r--r--mysys/my_handler.c1
-rw-r--r--mysys/my_redel.c37
-rw-r--r--mysys/stacktrace.c4
-rw-r--r--mysys/thr_lock.c3
12 files changed, 87 insertions, 39 deletions
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 337fc86c12e..95358883f4e 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -147,7 +147,3 @@ test_base64$(EXEEXT): base64.c $(LIBRARIES)
test_thr_mutex$(EXEEXT): test_thr_mutex.c $(LIBRARIES)
$(LINK) $(FLAGS) $(srcdir)/test_thr_mutex.c $(LDADD) $(LIBS)
-
-
-# Don't update the files from bitkeeper
-%::SCCS/s.%
diff --git a/mysys/errors.c b/mysys/errors.c
index fc63ac9d936..4c568952ee3 100644
--- a/mysys/errors.c
+++ b/mysys/errors.c
@@ -50,6 +50,8 @@ const char * NEAR globerrs[GLOBERRS]=
"Collation '%s' is not a compiled collation and is not specified in the '%s' file",
"File '%s' not found (Errcode: %d)",
"File '%s' (fileno: %d) was not closed",
+ "Can't change ownership of the file '%s' (Errcode: %d)",
+ "Can't change permissions of the file '%s' (Errcode: %d)",
"Can't change mode for file '%s' to 0x%lx (Error: %d)",
"Can't do seek on file '%s' (Errcode: %d)",
"Warning: Can't copy ownership for file '%s' (Error: %d)"
@@ -93,6 +95,8 @@ void init_glob_errs()
EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file";
EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %d)";
EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed";
+ EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %d)";
+ EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %d)";
EE(EE_CANT_CHMOD) = "Can't change mode for file '%s' to 0x%lx (Error: %d)";
EE(EE_CANT_SEEK) = "Can't do seek on file '%s' (Errcode: %d)";
EE(EE_CANT_COPY_OWNERSHIP)= "Warning: Can't copy ownership for file '%s' (Error: %d)";
diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c
index 59872961523..3824669365f 100644
--- a/mysys/mf_iocache.c
+++ b/mysys/mf_iocache.c
@@ -1701,16 +1701,19 @@ int my_block_write(register IO_CACHE *info, const uchar *Buffer, size_t Count,
#endif
-int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
+int my_b_flush_io_cache(IO_CACHE *info,
+ int need_append_buffer_lock __attribute__((unused)))
{
size_t length;
- my_bool append_cache;
my_off_t pos_in_file;
+ my_bool append_cache= (info->type == SEQ_READ_APPEND);
DBUG_ENTER("my_b_flush_io_cache");
DBUG_PRINT("enter", ("cache: 0x%lx", (long) info));
- if (!(append_cache = (info->type == SEQ_READ_APPEND)))
- need_append_buffer_lock=0;
+#ifdef THREAD
+ if (!append_cache)
+ need_append_buffer_lock= 0;
+#endif
if (info->type == WRITE_CACHE || append_cache)
{
diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c
index 4f7cd90e8aa..86fd61537e7 100644
--- a/mysys/mf_pack.c
+++ b/mysys/mf_pack.c
@@ -52,7 +52,7 @@ void pack_dirname(char * to, const char *from)
buff_length= strlen(buff);
d_length= (size_t) (start-to);
if ((start == to ||
- (buff_length == d_length && !bcmp(buff,start,d_length))) &&
+ (buff_length == d_length && !memcmp(buff,start,d_length))) &&
*start != FN_LIBCHAR && *start)
{ /* Put current dir before */
bchange((uchar*) to, d_length, (uchar*) buff, buff_length, strlen(to)+1);
@@ -70,7 +70,7 @@ void pack_dirname(char * to, const char *from)
}
if (length > 1 && length < d_length)
{ /* test if /xx/yy -> ~/yy */
- if (bcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR)
+ if (memcmp(to,home_dir,length) == 0 && to[length] == FN_LIBCHAR)
{
to[0]=FN_HOMELIB; /* Filename begins with ~ */
(void) strmov_overlapp(to+1,to+length);
@@ -80,7 +80,7 @@ void pack_dirname(char * to, const char *from)
{ /* Test if cwd is ~/... */
if (length > 1 && length < buff_length)
{
- if (bcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR)
+ if (memcmp(buff,home_dir,length) == 0 && buff[length] == FN_LIBCHAR)
{
buff[0]=FN_HOMELIB;
(void) strmov_overlapp(buff+1,buff+length);
@@ -166,7 +166,7 @@ size_t cleanup_dirname(register char *to, const char *from)
*pos = FN_LIBCHAR;
if (*pos == FN_LIBCHAR)
{
- if ((size_t) (pos-start) > length && bcmp(pos-length,parent,length) == 0)
+ if ((size_t) (pos-start) > length && memcmp(pos-length,parent,length) == 0)
{ /* If .../../; skip prev */
pos-=length;
if (pos != start)
@@ -197,7 +197,7 @@ size_t cleanup_dirname(register char *to, const char *from)
end_parentdir=pos;
while (pos >= start && *pos != FN_LIBCHAR) /* remove prev dir */
pos--;
- if (pos[1] == FN_HOMELIB || bcmp(pos,parent,length) == 0)
+ if (pos[1] == FN_HOMELIB || memcmp(pos,parent,length) == 0)
{ /* Don't remove ~user/ */
pos=strmov(end_parentdir+1,parent);
*pos=FN_LIBCHAR;
@@ -206,7 +206,7 @@ size_t cleanup_dirname(register char *to, const char *from)
}
}
else if ((size_t) (pos-start) == length-1 &&
- !bcmp(start,parent+1,length-1))
+ !memcmp(start,parent+1,length-1))
start=pos; /* Starts with "../" */
else if (pos-start > 0 && pos[-1] == FN_LIBCHAR)
{
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index 69e0ca18cb8..e7e5f75f486 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -550,7 +550,7 @@ uint bitmap_get_first(const MY_BITMAP *map)
{
byte_ptr= (uchar*)data_ptr;
for (j=0; ; j++, byte_ptr++)
- {
+ {
if (*byte_ptr != 0xFF)
{
for (k=0; ; k++)
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index adc891358d4..8ea9620b20b 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -17,6 +17,7 @@
#include "mysys_err.h"
#include <my_dir.h> /* for stat */
#include <m_string.h>
+#include "mysys_err.h"
#if defined(HAVE_UTIME_H)
#include <utime.h>
#elif defined(HAVE_SYS_UTIME_H)
@@ -57,7 +58,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
File from_file,to_file;
uchar buff[IO_SIZE];
MY_STAT stat_buff,new_stat_buff;
- int res;
+ my_bool file_created= 0;
DBUG_ENTER("my_copy");
DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags));
@@ -82,6 +83,7 @@ int my_copy(const char *from, const char *to, myf MyFlags)
MyFlags)) < 0)
goto err;
+ file_created= 1;
while ((Count=my_read(from_file, buff, sizeof(buff), MyFlags)) != 0)
{
if (Count == (uint) -1 ||
@@ -99,15 +101,30 @@ int my_copy(const char *from, const char *to, myf MyFlags)
if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags))
DBUG_RETURN(-1); /* Error on close */
+ from_file=to_file= -1; /* Files are closed */
+
/* Copy modes if possible */
if (MyFlags & MY_HOLD_ORIGINAL_MODES && !new_file_stat)
DBUG_RETURN(0); /* File copyed but not stat */
- res= chmod(to, stat_buff.st_mode & 07777); /* Copy modes */
+ /* Copy modes */
+ if (chmod(to, stat_buff.st_mode & 07777))
+ {
+ my_errno= errno;
+ if (MyFlags & MY_WME)
+ my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ if (MyFlags & MY_FAE)
+ goto err;
+ }
#if !defined(__WIN__) && !defined(__NETWARE__)
+ /* Copy ownership */
if (chown(to, stat_buff.st_uid,stat_buff.st_gid))
{
- my_error(EE_CANT_COPY_OWNERSHIP, MYF(ME_JUST_WARNING), to);
+ my_errno= errno;
+ if (MyFlags & MY_WME)
+ my_error(EE_CANT_COPY_OWNERSHIP, MYF(ME_JUST_WARNING), to, errno);
+ if (MyFlags & MY_FAE)
+ goto err;
}
#endif
#if !defined(VMS) && !defined(__ZTC__)
@@ -124,11 +141,11 @@ int my_copy(const char *from, const char *to, myf MyFlags)
err:
if (from_file >= 0) VOID(my_close(from_file,MyFlags));
- if (to_file >= 0)
- {
- VOID(my_close(to_file, MyFlags));
- /* attempt to delete the to-file we've partially written */
+ if (to_file >= 0) VOID(my_close(to_file, MyFlags));
+
+ /* attempt to delete the to-file we've partially written */
+ if (file_created)
VOID(my_delete(to, MyFlags));
- }
+
DBUG_RETURN(-1);
} /* my_copy */
diff --git a/mysys/my_gethwaddr.c b/mysys/my_gethwaddr.c
index c7f138c7337..00e0e90f1e4 100644
--- a/mysys/my_gethwaddr.c
+++ b/mysys/my_gethwaddr.c
@@ -47,7 +47,7 @@ my_bool my_gethwaddr(uchar *to)
uchar *buf, *next, *end, *addr;
struct if_msghdr *ifm;
struct sockaddr_dl *sdl;
- int i, res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0};
+ int res=1, mib[6]={CTL_NET, AF_ROUTE, 0, AF_LINK, NET_RT_IFLIST, 0};
if (sysctl(mib, 6, NULL, &len, NULL, 0) == -1)
goto err;
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index b8a5c5d14bd..d4e548611de 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -30,7 +30,7 @@ my_error_reporter my_getopt_error_reporter= &default_reporter;
static int findopt(char *optpat, uint length,
const struct my_option **opt_res,
- char **ffname);
+ const char **ffname);
my_bool getopt_compare_strings(const char *s,
const char *t,
uint length);
@@ -115,8 +115,8 @@ int handle_options(int *argc, char ***argv,
uint opt_found, argvpos= 0, length;
my_bool end_of_options= 0, must_be_var, set_maximum_value,
option_is_loose;
- char **pos, **pos_end, *optend, *UNINIT_VAR(prev_found),
- *opt_str, key_name[FN_REFLEN];
+ char **pos, **pos_end, *optend, *opt_str, key_name[FN_REFLEN];
+ const char *prev_found;
const struct my_option *optp;
void *value;
int error, i;
@@ -711,10 +711,10 @@ static int setval(const struct my_option *opts, void *value, char *argument,
static int findopt(char *optpat, uint length,
const struct my_option **opt_res,
- char **ffname)
+ const char **ffname)
{
uint count;
- struct my_option *opt= (struct my_option *) *opt_res;
+ const struct my_option *opt= *opt_res;
for (count= 0; opt->name; opt++)
{
@@ -725,8 +725,9 @@ static int findopt(char *optpat, uint length,
return 1;
if (!count)
{
+ /* We only need to know one prev */
count= 1;
- *ffname= (char *) opt->name; /* We only need to know one prev */
+ *ffname= opt->name;
}
else if (strcmp(*ffname, opt->name))
{
diff --git a/mysys/my_handler.c b/mysys/my_handler.c
index 7c13149cb27..efee04194f7 100644
--- a/mysys/my_handler.c
+++ b/mysys/my_handler.c
@@ -277,7 +277,6 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register const uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a+=a_length;
b+=b_length;
- break;
}
break;
case HA_KEYTYPE_INT8:
diff --git a/mysys/my_redel.c b/mysys/my_redel.c
index 598a728393d..cf0986a7821 100644
--- a/mysys/my_redel.c
+++ b/mysys/my_redel.c
@@ -71,14 +71,28 @@ end:
} /* my_redel */
- /* Copy stat from one file to another */
- /* Return -1 if can't get stat, 1 if wrong type of file */
+/**
+ Copy stat from one file to another
+ @fn my_copystat()
+ @param from Copy stat from this file
+ @param to Copy stat to this file
+ @param MyFlags Flags:
+ MY_WME Give error if something goes wrong
+ MY_FAE Abort operation if something goes wrong
+ If MY_FAE is not given, we don't return -1 for
+ errors from chown (which normally require root
+ privilege)
+
+ @return 0 ok
+ -1 if can't get stat,
+ 1 if wrong type of file
+*/
int my_copystat(const char *from, const char *to, int MyFlags)
{
struct stat statbuf;
- if (stat((char*) from, &statbuf))
+ if (stat(from, &statbuf))
{
my_errno=errno;
if (MyFlags & (MY_FAE+MY_WME))
@@ -87,7 +101,15 @@ int my_copystat(const char *from, const char *to, int MyFlags)
}
if ((statbuf.st_mode & S_IFMT) != S_IFREG)
return 1;
- VOID(chmod(to, statbuf.st_mode & 07777)); /* Copy modes */
+
+ /* Copy modes */
+ if (chmod(to, statbuf.st_mode & 07777))
+ {
+ my_errno= errno;
+ if (MyFlags & (MY_FAE+MY_WME))
+ my_error(EE_CHANGE_PERMISSIONS, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ return -1;
+ }
#if !defined(__WIN__) && !defined(__NETWARE__)
if (statbuf.st_nlink > 1 && MyFlags & MY_LINK_WARNING)
@@ -95,9 +117,14 @@ int my_copystat(const char *from, const char *to, int MyFlags)
if (MyFlags & MY_LINK_WARNING)
my_error(EE_LINK_WARNING,MYF(ME_BELL+ME_WAITTANG),from,statbuf.st_nlink);
}
+ /* Copy ownership */
if (chown(to, statbuf.st_uid, statbuf.st_gid))
{
- my_error(EE_CANT_COPY_OWNERSHIP, MYF(ME_JUST_WARNING), to);
+ my_errno= errno;
+ if (MyFlags & MY_WME)
+ my_error(EE_CHANGE_OWNERSHIP, MYF(ME_BELL+ME_WAITTANG), from, errno);
+ if (MyFlags & MY_FAE)
+ return -1;
}
#endif /* !__WIN__ && !__NETWARE__ */
diff --git a/mysys/stacktrace.c b/mysys/stacktrace.c
index 80122a4e70f..7bac8017324 100644
--- a/mysys/stacktrace.c
+++ b/mysys/stacktrace.c
@@ -86,7 +86,9 @@ void my_print_stacktrace(uchar* stack_bottom __attribute__((unused)),
#if BACKTRACE_DEMANGLE
-char __attribute__ ((weak)) *my_demangle(const char *mangled_name __attribute__((unused)), int *status __attribute__((unused)))
+char __attribute__ ((weak)) *
+my_demangle(const char *mangled_name __attribute__((unused)),
+ int *status __attribute__((unused)))
{
return NULL;
}
diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c
index c830c4ed0cc..b8aa9e5fcc0 100644
--- a/mysys/thr_lock.c
+++ b/mysys/thr_lock.c
@@ -131,8 +131,7 @@ static int check_lock(struct st_lock_list *list, const char* lock_type,
{
THR_LOCK_DATA *data,**prev;
uint count=0;
- THR_LOCK_OWNER *first_owner;
- LINT_INIT(first_owner);
+ THR_LOCK_OWNER *UNINIT_VAR(first_owner);
prev= &list->data;
if (list->data)