Getting root permissions

Hi, I am currently writing a little program that can partition and initialize a new hard drive from the console. The program is almost done but I need to log in as root to get permission to partition a HD.

I would like the program to be able to partition and format without logging in as root - I tried the function setuid() but that failed… Any good ideas ?

Thanks
/Rene

let’s assume the executable filename of your application is “myapp”:
su
chown root myapp
chmod u+s myapp
now you should be able to run “myapp” as a non-root user.