From e8156439f24137b5418baad20a7f00f6949cfe29 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 May 2007 09:30:34 +0000 Subject: r23183: Check in a change made by Tridge: This replaces the internal explicit dev/ino file id representation by a "struct file_id". This is necessary as cluster file systems and NFS don't necessarily assign the same device number to the shared file system. With this structure in place we can now easily add different schemes to map a file to a unique 64-bit device node. Jeremy, you might note that I did not change the external interface of smb_share_modes.c. Volker (This used to be commit 9b10dbbd5de8813fc15ebbb6be9b18010ffe8139) --- source3/lib/file_id.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 source3/lib/file_id.c (limited to 'source3/lib/file_id.c') diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c new file mode 100644 index 0000000000..335c1829fb --- /dev/null +++ b/source3/lib/file_id.c @@ -0,0 +1,102 @@ +/* + Unix SMB/CIFS implementation. + + file_id structure handling + + Copyright (C) Andrew Tridgell 2007 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" + +/* + return a file_id which gives a unique ID for a file given the device and + inode numbers + */ +static struct file_id file_id_create(SMB_DEV_T dev, SMB_INO_T inode) +{ + struct file_id key; + /* the ZERO_STRUCT ensures padding doesn't break using the key as a + * blob */ + ZERO_STRUCT(key); + key.devid = dev; + key.inode = inode; + return key; +} + +/* + generate a file_id from a stat structure + */ +struct file_id file_id_sbuf(const SMB_STRUCT_STAT *sbuf) +{ + return file_id_create(sbuf->st_dev, sbuf->st_ino); +} + + +/* + return True if two file_id structures are equal + */ +BOOL file_id_equal(const struct file_id *id1, const struct file_id *id2) +{ + return id1->inode == id2->inode && id1->devid == id2->devid; +} + +/* + a static string for a file_id structure + */ +const char *file_id_static_string(const struct file_id *id) +{ + static char buf[32]; + snprintf(buf, sizeof(buf), "%llx:%llx", + (unsigned long long)id->devid, + (unsigned long long)id->inode); + return buf; +} + +/* + a 2nd static string for a file_id structure so we can print 2 at once + */ +const char *file_id_static_string2(const struct file_id *id) +{ + static char buf[32]; + snprintf(buf, sizeof(buf), "%llx:%llx", + (unsigned long long)id->devid, + (unsigned long long)id->inode); + return buf; +} + +/* + push a 16 byte version of a file id into a buffer + */ +void push_file_id_16(char *buf, const struct file_id *id) +{ + SIVAL(buf, 0, id->devid&0xFFFFFFFF); + SIVAL(buf, 4, id->devid>>32); + SIVAL(buf, 8, id->inode&0xFFFFFFFF); + SIVAL(buf, 12, id->inode>>32); +} + +/* + pul a 16 byte version of a file id from a buffer + */ +void pull_file_id_16(char *buf, struct file_id *id) +{ + ZERO_STRUCTP(id); + id->devid = IVAL(buf, 0); + id->devid |= ((uint64_t)IVAL(buf,4))<<32; + id->inode = IVAL(buf, 8); + id->inode |= ((uint64_t)IVAL(buf,12))<<32; +} -- cgit From fb76516ccd06bd5d2e013d07c4477e28df74962a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 29 May 2007 10:48:42 +0000 Subject: r23185: Try to fix the IRIX build, also add the forgotten file_id.c in .26 (This used to be commit 5360e6405b170137e558fd0696ebd6030e0f5deb) --- source3/lib/file_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/file_id.c') diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c index 335c1829fb..18d3397bed 100644 --- a/source3/lib/file_id.c +++ b/source3/lib/file_id.c @@ -26,7 +26,7 @@ return a file_id which gives a unique ID for a file given the device and inode numbers */ -static struct file_id file_id_create(SMB_DEV_T dev, SMB_INO_T inode) +struct file_id file_id_create(SMB_DEV_T dev, SMB_INO_T inode) { struct file_id key; /* the ZERO_STRUCT ensures padding doesn't break using the key as a -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/lib/file_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/file_id.c') diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c index 18d3397bed..89bc372b5a 100644 --- a/source3/lib/file_id.c +++ b/source3/lib/file_id.c @@ -7,7 +7,7 @@ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or + the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/lib/file_id.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/lib/file_id.c') diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c index 89bc372b5a..11263af089 100644 --- a/source3/lib/file_id.c +++ b/source3/lib/file_id.c @@ -16,8 +16,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . */ #include "includes.h" -- cgit From 4b15f31f106f1dd69fdda721b5c3b787f5245a80 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 2 Aug 2007 08:53:24 +0000 Subject: r24120: add a file_id_create() hook into the VFS layer it's needed for some cluster filesystems to overload this function. metze (This used to be commit cdaa24e8047399002e4b287a31a8340a665e580f) --- source3/lib/file_id.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'source3/lib/file_id.c') diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c index 11263af089..a92cca08fa 100644 --- a/source3/lib/file_id.c +++ b/source3/lib/file_id.c @@ -25,7 +25,7 @@ return a file_id which gives a unique ID for a file given the device and inode numbers */ -struct file_id file_id_create(SMB_DEV_T dev, SMB_INO_T inode) +struct file_id file_id_create_dev(SMB_DEV_T dev, SMB_INO_T inode) { struct file_id key; /* the ZERO_STRUCT ensures padding doesn't break using the key as a @@ -39,12 +39,11 @@ struct file_id file_id_create(SMB_DEV_T dev, SMB_INO_T inode) /* generate a file_id from a stat structure */ -struct file_id file_id_sbuf(const SMB_STRUCT_STAT *sbuf) +struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_STAT *sbuf) { - return file_id_create(sbuf->st_dev, sbuf->st_ino); + return SMB_VFS_FILE_ID_CREATE(conn, sbuf->st_dev, sbuf->st_ino); } - /* return True if two file_id structures are equal */ -- cgit From 4ee8b2937d48308c6089fb539fdbd8625dfde360 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Sep 2007 10:56:07 +0000 Subject: r25055: Add file_id_string_tos This removes file_id_string_static and file_id_string_static2 (This used to be commit 638c848c9afe374feb30e34c494f89b2a6c64f7b) --- source3/lib/file_id.c | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) (limited to 'source3/lib/file_id.c') diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c index a92cca08fa..0a1913a9c2 100644 --- a/source3/lib/file_id.c +++ b/source3/lib/file_id.c @@ -55,25 +55,11 @@ BOOL file_id_equal(const struct file_id *id1, const struct file_id *id2) /* a static string for a file_id structure */ -const char *file_id_static_string(const struct file_id *id) +const char *file_id_string_tos(const struct file_id *id) { - static char buf[32]; - snprintf(buf, sizeof(buf), "%llx:%llx", - (unsigned long long)id->devid, - (unsigned long long)id->inode); - return buf; -} - -/* - a 2nd static string for a file_id structure so we can print 2 at once - */ -const char *file_id_static_string2(const struct file_id *id) -{ - static char buf[32]; - snprintf(buf, sizeof(buf), "%llx:%llx", - (unsigned long long)id->devid, - (unsigned long long)id->inode); - return buf; + return talloc_asprintf(talloc_tos(), "%llx:%llx", + (unsigned long long)id->devid, + (unsigned long long)id->inode); } /* -- cgit From bbbac99ecb26ee8ddf45defe0b22bf960bb6d4eb Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 10 Sep 2007 17:49:51 +0000 Subject: r25061: Pro-actively shut up Coverity :-) (This used to be commit f2ce4a803cfd04fa993d2d87720b4b6f67fc46db) --- source3/lib/file_id.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'source3/lib/file_id.c') diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c index 0a1913a9c2..8e8ddb0ab1 100644 --- a/source3/lib/file_id.c +++ b/source3/lib/file_id.c @@ -57,9 +57,11 @@ BOOL file_id_equal(const struct file_id *id1, const struct file_id *id2) */ const char *file_id_string_tos(const struct file_id *id) { - return talloc_asprintf(talloc_tos(), "%llx:%llx", - (unsigned long long)id->devid, - (unsigned long long)id->inode); + char *result = talloc_asprintf(talloc_tos(), "%llx:%llx", + (unsigned long long)id->devid, + (unsigned long long)id->inode); + SMB_ASSERT(result != NULL); + return result; } /* -- cgit From 30191d1a5704ad2b158386b511558972d539ce47 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 18 Oct 2007 17:40:25 -0700 Subject: RIP BOOL. Convert BOOL -> bool. I found a few interesting bugs in various places whilst doing this (places that assumed BOOL == int). I also need to fix the Samba4 pidl generation (next checkin). Jeremy. (This used to be commit f35a266b3cbb3e5fa6a86be60f34fe340a3ca71f) --- source3/lib/file_id.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/lib/file_id.c') diff --git a/source3/lib/file_id.c b/source3/lib/file_id.c index 8e8ddb0ab1..0633d4b88d 100644 --- a/source3/lib/file_id.c +++ b/source3/lib/file_id.c @@ -47,7 +47,7 @@ struct file_id vfs_file_id_from_sbuf(connection_struct *conn, const SMB_STRUCT_S /* return True if two file_id structures are equal */ -BOOL file_id_equal(const struct file_id *id1, const struct file_id *id2) +bool file_id_equal(const struct file_id *id1, const struct file_id *id2) { return id1->inode == id2->inode && id1->devid == id2->devid; } -- cgit