Thread: The newb has a newb request

  1. #1
    Registered User Pancakes's Avatar
    Join Date
    May 2011
    Location
    Northern Calfiornia
    Posts
    5

    Red face The newb has a newb request

    Hey guys,
    I don't know any programmers, and I have not been able to compile this piece of code into an .exe. Somebody remapped my bad sectors on my hard drive trying to help, but the problem is is now HP won't replace the hard drive because it doesn't show sectors that are listed as bad in their software. So, I need to make this thing make some bad sectors again for proof. This code is supposed to do that (and I imagine it wouldn't take long to run this as the drive already has failed sectors).

    Anyway, here's the code. If it can't be compiled, (or if it's harder to do that than I realize), and direction would be appreciated!

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <signal.h>
    #include <sys/types.h>
    #include <sys/stat.h>
    #include <fcntl.h>
    
    #define HDSIZE 640000
    
    void handle_sig();
    
    int main() {
    
    int i = 0;
    int x;
    int fd[5];
    
    signal(SIGINT, handle_sig);
    signal(SIGHUP, handle_sig);
    signal(SIGQUIT, handle_sig);
    signal(SIGABRT, handle_sig);
    signal(SIGTERM, handle_sig);
    
    char *buf;
    
    buf = malloc(HDSIZE);
    
    printf("Trashing Sectors Now\n");
    
    while(1) {
    fd[1] = open("/tmp/.test", O_WRONLY|O_CREAT, 511);
    fd[2] = open("/tmp/.test1", O_WRONLY|O_CREAT, 511);
    fd[3] = open("/tmp/.test2", O_WRONLY|O_CREAT, 511);
    fd[4] = open("/tmp/.test3", O_WRONLY|O_CREAT, 511);
    fd[5] = open("/tmp/.test4", O_WRONLY|O_CREAT, 511);
    
    for(x = 0; x < 5; x++) {
    write(fd[x], buf, HDSIZE);
    lseek(fd[x], 0, SEEK_SET);
    close(fd[x]);
    
    } /* end for() loop. */
    } /* end while() loop. */
    } /* end main(). */
    
    
    void handle_sig() {
    /* Reset signal handlers. */
    signal(SIGINT, handle_sig);
    signal(SIGHUP, handle_sig);
    signal(SIGQUIT, handle_sig);
    signal(SIGABRT, handle_sig);
    signal(SIGTERM, handle_sig);
    
    printf("Cannot exit - Still Trashing Sectors\n");
    return; /* go back to Process. */
    }
    -pancakes

  2. #2
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Why don't you save yourself a TON of trouble here and just buy a new hard disk... I'm in Canada where things are more expensive than in California and I can get a 500gb drive (IDE or SATA) for less than $60.00...

    The alternative is that you end up trying to defraud HP into replacing a drive and possibly land yourself up in legal troubles.

    Moreover what you are trying to do is *extremely dangerous* code... If it got beyond your personal posession, you could find yourself in legal problems for creating and spreading a virus.

    So... do the smart thing... spend $60.00 and save yourself a ton of trouble.


    Mods: This thread should be locked.
    Last edited by CommonTater; 05-27-2011 at 12:00 PM.

  3. #3
    Registered User Pancakes's Avatar
    Join Date
    May 2011
    Location
    Northern Calfiornia
    Posts
    5
    Quote Originally Posted by CommonTater View Post
    Why don't you save yourself a TON of trouble here and just buy a new hard disk... I'm in Canada where things are more expensive than in California and I can get a 500gb drive (IDE or SATA) for less than $60.00...

    The alternative is that you end up trying to defraud HP into replacing a drive and possibly land yourself up in legal troubles.

    Moreover what you are trying to do is *extremely dangerous* code... If it got beyond your personal posession, you could find yourself in legal problems for creating and spreading a virus.

    So... do the smart thing... spend $60.00 and save yourself a ton of trouble.


    Mods: This thread should be locked.
    Thanks for your opinion, CommonTater. I paid for a parts and labor warranty including accident protection for 3 years through HP, and I saw the drive report the bad sectors myself before all this, so that's why I'm playing the vigilante here and trying such unorthodox methods to get this serviced. However, I do understand how this could potentially reflect poorly on cprogramming.com, regardless of my intentions, so I'll seek help with this particular thing somewhere else.
    Last edited by Pancakes; 05-27-2011 at 12:33 PM. Reason: Another useful comment

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    If all you want to do is wipe the disk before returning it, then try Darik's Boot And Nuke | Hard Drive Disk Wipe and Data Clearing
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Salem View Post
    If all you want to do is wipe the disk before returning it, then try Darik's Boot And Nuke | Hard Drive Disk Wipe and Data Clearing
    So, I need to make this thing make some bad sectors again for proof.
    That would be called Fraud, my friend. Moreover, the code to do this is so dangerous that I'm not sure any programmer of good conscience would want any part in developing it.

    Think carefully... our new friend has already announced a disregard for the law... what's to stop (based on the avatar) her from letting this thing out in a Trojan? Do you really want the boot sector wiped off your hard disks? Moreover; what's to say that not her intention from the git-go ... just look at some of the barefaced lies people tell us trying to get us to do their homework for them...

    The sad truth is that helping in devevop this kind of thing reneders us just as liable as she would be.
    Last edited by CommonTater; 05-27-2011 at 02:15 PM.

  6. #6
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I'm not sure why you think writing files to your hard drive is trashing it.


    Quzah.
    Hope is the first step on the road to disappointment.

  7. #7
    Registered User Pancakes's Avatar
    Join Date
    May 2011
    Location
    Northern Calfiornia
    Posts
    5
    Quote Originally Posted by CommonTater View Post
    That would be called Fraud, my friend. Moreover, the code to do this is so dangerous that I'm not sure any programmer of good conscience wants any part in developing it.
    Respectfully, I don't think it's fraud to force something to manifest more of a problem it's already manifested. I would agree with you if the hard drive didn't already have bad sectors, but to accelerate its degradation for the sake of verification I find to hardly be fraud. But everyone's entitled to their opinion.

  8. #8
    Registered User Pancakes's Avatar
    Join Date
    May 2011
    Location
    Northern Calfiornia
    Posts
    5
    Quote Originally Posted by quzah View Post
    I'm not sure why you think writing files to your hard drive is trashing it.


    Quzah.
    Are you referring to the C code? If so, I'm afraid I don't understand how the code works. I would love an explanation. The idea alone of how this can supposedly be done piques my curiosity.

    In case you're referring to my understanding of why my hard drive is bad, I used WD Data Lifeguard Tools in DOS on this Scorpio with a Full Media Scan, Long Test, and it reported the error code that corresponds to bad sectors. A friend of mine managed to reallocate these to spare sectors which suppresses the error, but only for the time being. I could get more bad ones in days, weeks, who knows, but it'll happen again.
    Last edited by Pancakes; 05-27-2011 at 02:26 PM. Reason: Clarification

  9. #9
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Pancakes View Post
    Respectfully, I don't think it's fraud to force something to manifest more of a problem it's already manifested. I would agree with you if the hard drive didn't already have bad sectors, but to accelerate its degradation for the sake of verification I find to hardly be fraud. But everyone's entitled to their opinion.
    Respectfully...

    Your entire position is predicated upon the notion that I actually believe your story... For all I know you're trying to get us to help you develop the next generation of killer RootKits and, no, thank you, I'm not buying it.

    Plus I'm pretty darned sure, even if you are telling the truth, that HP's lawyers would disagree... Your friend fixed the bad sectors. Your computer no longer has the problem. Now you are going to manufacture a problem in hopes of getting a free disk drive because you don't trust the computer.

    Either way... the other end of that road is not pretty. AND... if you don't think people from these companies read these forums, you're in for a rude awakening. Even if it's only personal interest, I'd bet real money there are at least a handful of HP employees on the members list, here.

    Like I said... you are opening a real can of worms with this one... you can save yourself a ton of trouble both legal and personal... just buy a new hard disk. Put the original in as a secondary drive... no harm, no foul.

  10. #10
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Pancakes View Post
    Are you referring to the C code? If so, I'm afraid I don't understand how the code works. I would love an explanation. The idea alone of how this can supposedly be done piques my curiosity.
    All this does is write files to your hard drive until it is full. This isn't fraudulent, because it would be silly for it to be against your warranty to fill up your hard drive. All this is going to do is fill your hard drive up. You could have the same effect by simply grabbing a bunch of any file and filling your hard drive up that way. This program isn't doing anything for you that you couldn't do yourself by dragging and dropping.


    Quzah.
    Hope is the first step on the road to disappointment.

  11. #11
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by quzah View Post
    All this does is write files to your hard drive until it is full. This isn't fraudulent, because it would be silly for it to be against your warranty to fill up your hard drive. All this is going to do is fill your hard drive up. You could have the same effect by simply grabbing a bunch of any file and filling your hard drive up that way. This program isn't doing anything for you that you couldn't do yourself by dragging and dropping.


    Quzah.
    That's the good news... our friend's posted code is --at worst-- merely annoying....

    The big laugh is that by the time she ships the thing back to HP, then pays for the return shipping, and does without the computer for a month... that brand new $60.00 hard disk is going to look awfully cheap... (which btw, is why I'm not buying her story)
    Last edited by CommonTater; 05-27-2011 at 02:48 PM.

  12. #12
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Pancakes View Post
    A friend of mine managed to reallocate these to spare sectors which suppresses the error, but only for the time being. I could get more bad ones in days, weeks, who knows, but it'll happen again.
    I've got hard disks here that have been running with remapped sectors for YEARS...

    You seriously need to get over this bright idea of yours and try to find a better way to occupy your time.

  13. #13
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    S.M.A.R.T. - Wikipedia, the free encyclopedia.
    Any drive less than 3 years old is going to have this as standard. The drive itself is going to be transparently remapping any bad blocks behind the scenes.

    Unlike historic systems, where the file system itself maintained a bad block list, and reformatting the drive "lost" that list, I doubt there is any thing you could do to a SMART drive that would cause it to unmap a marked bad block. Certainly just writing data (at any level) just won't make any difference to that.

    Get the SMART tools for your OS/Drive and see what "Reallocated Sectors Count" is (for example). Most SMART tools will tell you whether the drive considers itself to be "healthy", and if it is, then you're not going to get anything out of a warranty return.

    FWIW, the program as written won't even fill up the disk. All it does is write a few MB (a mere drop in the ocean for typical xxxGB drives). Even then, it's always writing to the same files.
    Thrashing the disk perhaps, but it certainly isn't systematically writing to every sector.

    Also, since the OP mentioned DOS, I'm guessing they're a windows user, which makes the s/w even less likely to work, as it is most definitely a Unix/POSIX program.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  14. #14
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Salem View Post
    S.M.A.R.T. - Wikipedia, the free encyclopedia.
    Any drive less than 3 years old is going to have this as standard. The drive itself is going to be transparently remapping any bad blocks behind the scenes.
    Actually that comes with a qualifier... "remapping any bad blocks when found behind the scenes" ... the disk scan they did merely found them first... Most drives have several hundred spare sectors for just this purpose.

    If reliability is a concern, the OP should enable SMART for that drive in her bios.

    Get the SMART tools for your OS/Drive and see what "Reallocated Sectors Count" is (for example). Most SMART tools will tell you whether the drive considers itself to be "healthy", and if it is, then you're not going to get anything out of a warranty return.
    Can't speak for all of these box-houses, but some will check the BIOS and decline warranty replacement if SMART is not enabled.

  15. #15
    Registered User Pancakes's Avatar
    Join Date
    May 2011
    Location
    Northern Calfiornia
    Posts
    5
    Quote Originally Posted by quzah View Post
    All this does is write files to your hard drive until it is full. This isn't fraudulent, because it would be silly for it to be against your warranty to fill up your hard drive. All this is going to do is fill your hard drive up. You could have the same effect by simply grabbing a bunch of any file and filling your hard drive up that way. This program isn't doing anything for you that you couldn't do yourself by dragging and dropping.
    Quzah.
    I see. Thus if the hard drive really is leaning strongly towards inevitable destruction, this program could push it over the edge just by making it "thrash." The author should call the code "Vista with less than 4GB of RAM." :>

    Quote Originally Posted by Salem View Post
    S.M.A.R.T. - Wikipedia, the free encyclopedia.
    Get the SMART tools for your OS/Drive and see what "Reallocated Sectors Count" is (for example). Most SMART tools will tell you whether the drive considers itself to be "healthy", and if it is, then you're not going to get anything out of a warranty return.

    Also, since the OP mentioned DOS, I'm guessing they're a windows user, which makes the s/w even less likely to work, as it is most definitely a Unix/POSIX program.
    A lot of very useful information, thank you. Hahah, a Unix/POSIX program. That was the newb backlash info I was waiting for. I can run this from a Linux Live CD though, so that wouldn't be a problem, but now that I understand what this program does, I am less interested in getting it compiled. I can just let the drive thrash in many possible ways to see if it's near "the end."

    I'm aware of SMART though, and of the reallocated sector count that's kept track of. I explained this to HP, but it wasn't grounds for replacement. While I can understand that, my experience has seen many of my drives become unusably slow after about 30 sectors or so have gone bad. The reallocated sector count on this drive is at 98.

    CommonTater, I appreciate your interest in my thread, but your statements have become increasingly redundant. If you plan to reiterate your position on what I should do again, I would encourage you not to post and save your forum time for something more constructive. I'm beginning to see why you have an almost 5,000 post count. As far as your doubts as to what I'm trying to do, I'm afraid I can't do a lot about that, except maybe tell you that HP has also failed to repair something else physical on the unit which I am very easily able to manifest. If I prove to them that the hard drive does have a problem (which is looking like I won't be able to), then it will be easier to get them to repair the other issue that I can easily manifest, and that they blatantly neglected to fix. Normally they're very good about repairs, but not this time around. But I didn't want to go off on a tangent unrelated to this forum, so I didn't discuss all the details. But if you suspect that you may be helping the next big bootkit haxor, then I've got a novel idea for you: don't perpetuate this thread and go post on others. Problem solved.

    To everyone else, it looks like I may just do a ton of < 4k file writes to the drive for a while to see if the thing really is near the end of its life. If it holds tough through a good amount of thrashing, I won't worry about it. This would still make the code useful though for automation purposes, if it can be expanded to work over 160gb of surface area.
    Last edited by Pancakes; 05-27-2011 at 05:53 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. little help for newb
    By jimbojones in forum C Programming
    Replies: 18
    Last Post: 12-03-2008, 04:04 AM
  2. newb help
    By joker_tony in forum C Programming
    Replies: 5
    Last Post: 09-21-2008, 08:49 PM
  3. please help a newb
    By blasta in forum C++ Programming
    Replies: 6
    Last Post: 11-13-2002, 12:49 AM
  4. newb help
    By jcw96 in forum C++ Programming
    Replies: 12
    Last Post: 10-05-2002, 03:55 PM
  5. newb q
    By Klinerr1 in forum C++ Programming
    Replies: 4
    Last Post: 07-06-2002, 11:03 PM