DSM-G600, DNS-3xx and NSA-220 Hack Forum

Unfortunately no one can be told what fun_plug is - you have to see it for yourself.

You are not logged in.

Announcement

#1 2008-08-09 21:46:40

Paladine
New member
Registered: 2008-08-09
Posts: 4

Can't overwrite files on device mounted with cifs

I wrote a little backup script that runs daily as a cronjob.  It automounts the device, copies some files, and then unmounts the device.  It was working great with 1.04 but with the upgrade to 1.05 it fails.  Here's the script

Code:

#!/bin/sh

DEST=/raidauto/Important
MOUNT=/raidauto

mount $MOUNT || { echo "Cannot mount $MOUNT"; exit 1; }

if [ ! -d $DEST ]; then
  echo "Cannot find $DEST for backup"
  umount $MOUNT
  exit 1
fi

cp ~/docs/finances/money $DEST/

umount $MOUNT

Here's the entry in my fstab:

Code:

//dns-323/Volume_1 /raidauto    cifs            rw,noauto,user,username=default,pass=media 0 0

The error I get is: cp: cannot create regular file `/raidauto/Important/money': No such file or directory
The funny thing is, if I modify the script to delete /raidauto/Important/money and then perform the cp, it works just fine.  So I can apparently create new files, but can't overwrite them.  I am baffled.  I even wrote a little test program and it fails in the same way as cp does

Code:

#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>

int main()
{
  int fd = open("/raidauto/Important/money", O_CREAT|O_WRONLY|O_TRUNC);
  if (fd < 0)
    fprintf(stderr,"Error = %i\n",errno);
  else
    close(fd);

  return 0;
}

Any suggestions????

Offline

 

#2 2009-02-01 17:00:59

Paladine
New member
Registered: 2008-08-09
Posts: 4

Re: Can't overwrite files on device mounted with cifs

Still having this same issue, any ideas?

Code:

-rwxrwx--- 1 502 media 416419 Dec 18 20:00 /raidauto/Important/money

groups i belong to

Code:

wheel cron audio cdrom video games media tcj scanner vmware

Updated sample code

Code:

#include <stdio.h>
#include <fcntl.h>
#include <errno.h>

const char *path = "/raidauto/Important/money";

int main(int argc,char **argv)
{
  int fd = open(path,O_RDONLY);
  if (fd >= 0)
  {
    printf("Opened file\n");
    close(fd);
  }
  else
  {
    printf("Failed to open file %d\n",errno);
  }

  fd = open(path,O_WRONLY | O_TRUNC);
  if (fd >= 0)
  {
    printf("Opened file\n");
    close(fd);
  }
  else
  {
    printf("Failed to open file %d\n",errno);
  }
  return 0;
}

Output is

Code:

Opened file
Failed to open file 2

Error code 2 is no such file or directory, which is obviously wrong because I just opened it for reading immediately before that!
CIFS reports in dmesg

Code:

 fs/cifs/transport.c: For smb_command 50
 fs/cifs/transport.c: Sending smb of length 152
 fs/cifs/connect.c: rfc1002 length 0x27
 fs/cifs/connect.c: invalid transact2 word count
Status code returned 0xc0000034 NT_STATUS_OBJECT_NAME_NOT_FOUND
 fs/cifs/netmisc.c: Mapping smb error code 2 to POSIX err -2
 fs/cifs/cifssmb.c: SetPathInfo (file size) returned -2
 fs/cifs/inode.c: SetEOF by path (setattrs) rc = -2
 fs/cifs/inode.c: CIFS VFS: leaving cifs_setattr_unix (xid = 105171) rc = -2

Offline

 

#3 2009-02-02 08:51:51

madpenguin
Member
Registered: 2008-12-25
Posts: 77

Re: Can't overwrite files on device mounted with cifs

Yea. I get the same thing. I'm rarely in linux these days so I never bothered to troubleshoot it. I correlated it with a samba upgrade on the workstation but I could be wrong. I believe 3.2.4 worked fine but when I upgraded to 3.2.6 I started seeing this behavior.

Seems like a uid/gid issue. Most of the data on my NAS is admin:500. Play around with chown on the NAS or create an identical user/group on linux to do the transfer. Should be able to pinpoint it fairly quickly by doing that I think.

Just a guess anyway.

Offline

 

#4 2009-02-03 05:28:17

Paladine
New member
Registered: 2008-08-09
Posts: 4

Re: Can't overwrite files on device mounted with cifs

Solution found at http://www.zeitoun.net/articles/dsn323- … bug/start.

The easiest route is to upgrade to 2.6.28, and use nodfs as a mount option.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2010 PunBB