Fix inode generation so nautilus can count total dir size correctly
[samba.git] / source3 / lib / util.c
index 91b8436d1170124f322aa5bceeb0dc051a6648ac..46be349a2c22d0253642eaecc72ea96e35f078af 100644 (file)
@@ -382,6 +382,16 @@ int get_cmdline_auth_info_signing_state(const struct user_auth_info *auth_info)
        return auth_info->signing_state;
 }
 
+void set_cmdline_auth_info_use_ccache(struct user_auth_info *auth_info, bool b)
+{
+        auth_info->use_ccache = b;
+}
+
+bool get_cmdline_auth_info_use_ccache(const struct user_auth_info *auth_info)
+{
+       return auth_info->use_ccache;
+}
+
 void set_cmdline_auth_info_use_kerberos(struct user_auth_info *auth_info,
                                        bool b)
 {
@@ -527,13 +537,14 @@ void set_cmdline_auth_info_getpass(struct user_auth_info *auth_info)
  Check if a file exists - call vfs_file_exist for samba files.
 ********************************************************************/
 
-bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf)
+bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf,
+                    bool fake_dir_create_times)
 {
        SMB_STRUCT_STAT st;
        if (!sbuf)
                sbuf = &st;
 
-       if (sys_stat(fname, sbuf, lp_fake_dir_create_times()) != 0)
+       if (sys_stat(fname, sbuf, fake_dir_create_times) != 0)
                return(False);
 
        return((S_ISREG(sbuf->st_ex_mode)) || (S_ISFIFO(sbuf->st_ex_mode)));
@@ -546,33 +557,12 @@ bool file_exist_stat(const char *fname,SMB_STRUCT_STAT *sbuf)
 bool socket_exist(const char *fname)
 {
        SMB_STRUCT_STAT st;
-       if (sys_stat(fname, &st, lp_fake_dir_create_times()) != 0)
+       if (sys_stat(fname, &st, false) != 0)
                return(False);
 
        return S_ISSOCK(st.st_ex_mode);
 }
 
-/*******************************************************************
- Check if a directory exists.
-********************************************************************/
-
-bool directory_exist_stat(char *dname,SMB_STRUCT_STAT *st)
-{
-       SMB_STRUCT_STAT st2;
-       bool ret;
-
-       if (!st)
-               st = &st2;
-
-       if (sys_stat(dname, st, lp_fake_dir_create_times()) != 0)
-               return(False);
-
-       ret = S_ISDIR(st->st_ex_mode);
-       if(!ret)
-               errno = ENOTDIR;
-       return ret;
-}
-
 /*******************************************************************
  Returns the size in bytes of the named given the stat struct.
 ********************************************************************/
@@ -590,7 +580,7 @@ SMB_OFF_T get_file_size(char *file_name)
 {
        SMB_STRUCT_STAT buf;
        buf.st_ex_size = 0;
-       if (sys_stat(file_name, &buf, lp_fake_dir_create_times()) != 0)
+       if (sys_stat(file_name, &buf, false) != 0)
                return (SMB_OFF_T)-1;
        return get_file_size_stat(&buf);
 }
@@ -1417,7 +1407,7 @@ uid_t nametouid(const char *name)
        char *p;
        uid_t u;
 
-       pass = getpwnam_alloc(talloc_autofree_context(), name);
+       pass = Get_Pwnam_alloc(talloc_autofree_context(), name);
        if (pass) {
                u = pass->pw_uid;
                TALLOC_FREE(pass);
@@ -2007,17 +1997,8 @@ const char *tab_depth(int level, int depth)
 
 int str_checksum(const char *s)
 {
-       int res = 0;
-       int c;
-       int i=0;
-
-       while(*s) {
-               c = *s;
-               res ^= (c << (i % 15)) ^ (c >> (15-(i%15)));
-               s++;
-               i++;
-       }
-       return(res);
+       TDB_DATA key = string_tdb_data(s);
+       return jenkins_hash(&key);
 }
 
 /*****************************************************************
@@ -3080,3 +3061,14 @@ const char *strip_hostname(const char *s)
 
        return s;
 }
+
+bool tevent_req_poll_ntstatus(struct tevent_req *req,
+                             struct tevent_context *ev,
+                             NTSTATUS *status)
+{
+       bool ret = tevent_req_poll(req, ev);
+       if (!ret) {
+               *status = map_nt_error_from_unix(errno);
+       }
+       return ret;
+}