Sponsored Content
Full Discussion: Computing an MD5Sum in C
Top Forums Programming Computing an MD5Sum in C Post 302411807 by snag49ers on Friday 9th of April 2010 12:56:45 PM
Old 04-09-2010
Thanks itkamaraj. The problem I'm having now though is that I am scanning the directory so the file that I'm using is stored in entry->d_name and when I call system("md5sum entry->d_name") it is actually trying to use entry->d_name instead of the actual filename. Do you know how I can get around this? Here's some of my code

Code:
while( ( entry = readdir( dp ) ) != NULL )
    {
        lstat( entry->d_name, &statbuf );
        
        if( S_ISDIR( statbuf.st_mode ) )
        {
            if( strcmp( ".", entry->d_name ) == 0 || strcmp( "..", entry->d_name ) == 0 )
            {
                continue;
            }
            
            printf( "%*s%s/\n", depth, "", entry->d_name );
            printdir( entry->d_name, depth+4 );
        }
        else
        {
            unsigned int md5;
            md5 = system("md5sum entry->d_name");
            printf( "%*s%s%d\n", depth, "", entry->d_name, md5 );
        }
        
    }

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What is md5sum???

Hi all, I am kinda puzzled. When and Why do we use md5sum? I've read man pages for mp5sum, but didn't get anything out of it. Please, can someone explain this to me in couple of words. Thank you all. (1 Reply)
Discussion started by: solvman
1 Replies

2. UNIX for Dummies Questions & Answers

the file: MD5SUM

i downloaded a Linux distribution from a FTP site today, and i found there is a file named MD5SUM in the same directory, with the following contents: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 c9a4d963a49e384e10dec9c2bd49ad73 valhalla-SRPMS-disc1.iso 41b03d068e84d2a17147aa27e704f79b ... (1 Reply)
Discussion started by: samprax
1 Replies

3. Virtualization and Cloud Computing

Event Cloud Computing - IBM Turning Data Centers Into ?Computing Cloud?

Tim Bass Thu, 15 Nov 2007 23:55:07 +0000 *I predict we may experience less*debates*on the use of the term “event cloud”*related to*CEP in the future, now that both IBM and Google* have made announcements about “cloud computing” and “computing cloud”, IBM Turning Data Centers Into ‘Computing... (0 Replies)
Discussion started by: Linux Bot
0 Replies

4. Programming

md5sum and execve

Hello there! Is there a way to use execve() to run md5sum function? for example execve("md5sum <filename>, NULL,NULL);" thanx! (2 Replies)
Discussion started by: nicos
2 Replies

5. Shell Programming and Scripting

how to get a md5sum in perl

hi All: i write a adduser script in perl , but I don't know how to deal with the password , for it stored as md5. and i don't use the shell command passwd. give me some advice...thanks (1 Reply)
Discussion started by: kingdream
1 Replies

6. Shell Programming and Scripting

md5sum in different linux

something strange is that i find the md5sum command in different linux generate different result, for example, i have tried the same file in CentOS and Rhel, The md5 results are different, it is quite headache, who know the tricks? (3 Replies)
Discussion started by: zbc
3 Replies

7. Shell Programming and Scripting

Md5sum script

Hello, I need to download multiple files from an FTP server but occasionally they arrive in error so I need to perform an integrity check. I've been attempting to write a bash script that does the following: Downloads all files including those in sub directories Perform md5sum using... (4 Replies)
Discussion started by: shadyuk
4 Replies

8. Shell Programming and Scripting

Md5sum on crontab

Hi all, I have to verify the integrity of a ISO image that is downloaded periodically on my PC. In order to do that, I've written a bash script that use the command md5sum with the aim to match the generated code with the default one created with the SIO image. The problem is that, if I start... (1 Reply)
Discussion started by: Mr. Piros
1 Replies

9. Shell Programming and Scripting

Compare two md5sum

Hello, First of all I want to apologize because i'm not a admin or coder and maybe all my efforts to write only this small script in my life would need one week full time reading man pages and forums but... I don't have the money to offer me to get this time and the script I want to do seems... (5 Replies)
Discussion started by: toscan
5 Replies

10. Shell Programming and Scripting

[md5sum] script

I am getting No such file or directory if my variable contains white spaces... Is there a way to fix this? This works x="1.md5" md5sum -c "$x" This, does not x="23\ 5\ 6\ 7\ 8\ 9\ 10.md5" md5sum -c "$x" md5sum: '23\ 5\ 6\ 7\ 8\ 9\ 10.md5': No such file or directory How do I fix... (1 Reply)
Discussion started by: soichiro
1 Replies
dir_ufs(4)							   File Formats 							dir_ufs(4)

NAME
dir_ufs, dir - format of ufs directories SYNOPSIS
#include <sys/param.h> #include <sys/types.h> #include <sys/fs/ufs_fsdir.h> DESCRIPTION
A directory consists of some number of blocks of DIRBLKSIZ bytes, where DIRBLKSIZ is chosen such that it can be transferred to disk in a single atomic operation, for example, 512 bytes on most machines. Each DIRBLKSIZ-byte block contains some number of directory entry structures, which are of variable length. Each directory entry has a struct direct at the front of it, containing its inode number, the length of the entry, and the length of the name contained in the entry. These entries are followed by the name padded to a 4 byte boundary with null bytes. All names are guaranteed null-terminated. The maximum length of a name in a directory is MAXNAMLEN. #define DIRBLKSIZ DEV_BSIZE #define MAXNAMLEN 256 struct direct { ulong_t d_ino; /* inode number of entry */ ushort_t d_reclen; /* length of this record */ ushort_t d_namlen; /* length of string in d_name */ char d_name[MAXNAMLEN + 1]; /* maximum name length */ }; ATTRIBUTES
See attributes(5) for a description of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Interface Stability |Unstable | +-----------------------------+-----------------------------+ SEE ALSO
attributes(5), ufs(7FS) SunOS 5.11 16 Apr 2003 dir_ufs(4)
All times are GMT -4. The time now is 02:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy