Three small problems at work/personnal today.
I had to update the kernel of my boss's computer (running Ubuntu) in order to change an include.h into the GNU/Linux kernel (no more modification in the kernel). Then, I rebooted the computer but the data partition was not mounted. Getting stuff like :
root@scully:/# mount /data/
mount: /dev/hdb1 already mounted or /data busy
Of course, hdb1 is not mounted and /data is not busy (fuser -v /data is your friend).
After a few investigation, I found that evms is trying to access to the drive on boot and I guess it is not releasing the hard drive properly or something like that.
Nov 02 17:07:28 scully _5_ Engine: is_volume_change_pending: Change pending: Volume /dev/evms/hdb1 needs to be activated.
The dirty workaround is to launch evms AFTER the mount all options.
mv /etc/rcS.d/S27evms /etc/rcS.d/S99evms
Be carreful, this could cause side effects.
I had to debug an issue under the linux version of our softwares. Impossible to read big files (over 2 go).
Then, I created a fake file of 3 go and made a small program to reproduce the issue.
Here is the source :
#include
void myRead(FILE * fichier){
/*lit le fichier caractere par caractere*/
char buf;
int ret=1;
if (fichier!=NULL)
do
{
ret=fread(&buf,sizeof(char),1,fichier);
printf("%c",buf);
}while(!feof(fichier));
}
int main () {
FILE *myFile = fopen( "bigfile","r" );
if (myFile!=NULL) {
myRead(myFile);
}else{
printf("myFile not opened");
}
return 0;
}
Amazing, isn't it ?
When I run this program (after tsize testsize.cpp), I only get a myFile not opened.
Launching again this software with strace and I can see in the middle of the dump a :
open("bigfile", O_RDONLY) = -1 EFBIG (File too large)
After a few links, I finally found the solution :
Add at the beginning of the source (before some includes) these three lines
#define _FILE_OFFSET_BITS 64
=> defines which interface will be used by default
#define _LARGEFILE64_SOURCE
=> permits the use of 64 bits functions
#define _LARGEFILE_SOURCE
=> permits the use of fseeko() and ftello()
Of course, it is possible to specify these define in the g++ command line like that : g++ -D_FILE_OFFSET_BITS=64 -o testsize testsize.cpp
source
-
Last but not least (I like this expression), an trick avoid stealer to make a direct link to one of your image on their website and wasting your bandwith. Personally, I don't care. I have plenty of bandwith and it represents a small part of the current traffic.
However, I had to fix this problem for a website which offers legal mp3 & avi.
The trick consists of using mod_rewrite. It checks the referent and if it is not from the official website and that it is trying to reach a file with a specific extension (mp3 and so on), we redirect the navigator to an other URL.
Just put this few lines into your .htaccess and it should do it (if you have access to mod_rewrite for your website) :
DirectoryIndex index.php
RewriteEngine On
# Rewrite Rules for files
# if the referent is not empty
RewriteCond %{HTTP_REFERER} !^$
# if the domain is not our
RewriteCond %{HTTP_REFERER} !^(.*)(domain.com|domain.com.au)(.*)$
# if the extension if in the list
RewriteCond %{REQUEST_URI} \.(mp3|wmv|wma|zip|avi|mpg)$ [NC]
# Redirect to an URL
RewriteRule ^(.*)$ http://sylvestre.ledru.info/ [L]
Pretty simple isn't it ?
PS : why this image ? Well, this post is too technical... This picture has been taken last week end in Sealers Cove in Wilson 's Promontory in Victoria.
Edit : comments are closed. Thank you spammer.