Example #1
0
static void print_brl(struct file_id id,
                      struct server_id pid,
                      enum brl_type lock_type,
                      enum brl_flavour lock_flav,
                      br_off start,
                      br_off size,
                      void *private_data)
{
    static int count;
    int i;
    static const struct {
        enum brl_type lock_type;
        const char *desc;
    } lock_types[] = {
        { READ_LOCK, "R" },
        { WRITE_LOCK, "W" },
        { PENDING_READ_LOCK, "PR" },
        { PENDING_WRITE_LOCK, "PW" },
        { UNLOCK_LOCK, "U" }
    };
    const char *desc="X";
    const char *sharepath = "";
    char *fname = NULL;
    struct share_mode_lock *share_mode;

    if (count==0) {
        d_printf("Byte range locks:\n");
        d_printf("Pid        dev:inode       R/W  start     size      SharePath               Name\n");
        d_printf("--------------------------------------------------------------------------------\n");
    }
    count++;

    share_mode = fetch_share_mode_unlocked(NULL, id);
    if (share_mode) {
        bool has_stream = share_mode->stream_name != NULL;

        fname = talloc_asprintf(NULL, "%s%s%s", share_mode->base_name,
                                has_stream ? ":" : "",
                                has_stream ? share_mode->stream_name :
                                "");
    } else {
        fname = talloc_strdup(NULL, "");
        if (fname == NULL) {
            return;
        }
    }

    for (i=0; i<ARRAY_SIZE(lock_types); i++) {
        if (lock_type == lock_types[i].lock_type) {
            desc = lock_types[i].desc;
        }
    }

    d_printf("%-10s %-15s %-4s %-9.0f %-9.0f %-24s %-24s\n",
             procid_str_static(&pid), file_id_string_tos(&id),
             desc,
             (double)start, (double)size,
             sharepath, fname);

    TALLOC_FREE(fname);
    TALLOC_FREE(share_mode);
}
Example #2
0
BOOL rename_share_filename(struct share_mode_lock *lck,
			const char *servicepath,
			const char *newname)
{
	size_t sp_len;
	size_t fn_len;
	size_t msg_len;
	char *frm = NULL;
	int i;

	if (!lck) {
		return False;
	}

	DEBUG(10, ("rename_share_filename: servicepath %s newname %s\n",
		servicepath, newname));

	/*
	 * rename_internal_fsp() and rename_internals() add './' to
	 * head of newname if newname does not contain a '/'.
	 */
	while (newname[0] && newname[1] && newname[0] == '.' && newname[1] == '/') {
		newname += 2;
	}

	lck->servicepath = talloc_strdup(lck, servicepath);
	lck->filename = talloc_strdup(lck, newname);
	if (lck->filename == NULL || lck->servicepath == NULL) {
		DEBUG(0, ("rename_share_filename: talloc failed\n"));
		return False;
	}
	lck->modified = True;

	sp_len = strlen(lck->servicepath);
	fn_len = strlen(lck->filename);

	msg_len = MSG_FILE_RENAMED_MIN_SIZE + sp_len + 1 + fn_len + 1;

	/* Set up the name changed message. */
	frm = TALLOC_ARRAY(lck, char, msg_len);
	if (!frm) {
		return False;
	}

	SDEV_T_VAL(frm,0,lck->dev);
	SINO_T_VAL(frm,8,lck->ino);

	DEBUG(10,("rename_share_filename: msg_len = %u\n", (unsigned int)msg_len ));

	safe_strcpy(&frm[16], lck->servicepath, sp_len);
	safe_strcpy(&frm[16 + sp_len + 1], lck->filename, fn_len);

	/* Send the messages. */
	for (i=0; i<lck->num_share_modes; i++) {
		struct share_mode_entry *se = &lck->share_modes[i];
		if (!is_valid_share_mode_entry(se)) {
			continue;
		}
		/* But not to ourselves... */
		if (procid_is_me(&se->pid)) {
			continue;
		}

		DEBUG(10,("rename_share_filename: sending rename message to pid %s "
			"dev %x, inode  %.0f sharepath %s newname %s\n",
			procid_str_static(&se->pid),
			(unsigned int)lck->dev, (double)lck->ino,
			lck->servicepath, lck->filename ));

		message_send_pid(se->pid, MSG_SMB_FILE_RENAME,
				frm, msg_len, True);
	}

	return True;
}
Example #3
0
static void print_share_mode(const struct share_mode_entry *e,
                             const char *sharepath,
                             const char *fname,
                             void *dummy)
{
    static int count;

    if (!is_valid_share_mode_entry(e)) {
        return;
    }

    if (!process_exists(e->pid)) {
        return;
    }

    if (count==0) {
        d_printf("Locked files:\n");
        d_printf("Pid          Uid        DenyMode   Access      R/W        Oplock           SharePath   Name   Time\n");
        d_printf("--------------------------------------------------------------------------------------------------\n");
    }
    count++;

    if (Ucrit_checkPid(e->pid)) {
        d_printf("%-11s  ",procid_str_static(&e->pid));
        d_printf("%-9u  ", (unsigned int)e->uid);
        switch (map_share_mode_to_deny_mode(e->share_access,
                                            e->private_options)) {
        case DENY_NONE:
            d_printf("DENY_NONE  ");
            break;
        case DENY_ALL:
            d_printf("DENY_ALL   ");
            break;
        case DENY_DOS:
            d_printf("DENY_DOS   ");
            break;
        case DENY_READ:
            d_printf("DENY_READ  ");
            break;
        case DENY_WRITE:
            printf("DENY_WRITE ");
            break;
        case DENY_FCB:
            d_printf("DENY_FCB ");
            break;
        default: {
            d_printf("unknown-please report ! "
                     "e->share_access = 0x%x, "
                     "e->private_options = 0x%x\n",
                     (unsigned int)e->share_access,
                     (unsigned int)e->private_options );
            break;
        }
        }
        d_printf("0x%-8x  ",(unsigned int)e->access_mask);
        if ((e->access_mask & (FILE_READ_DATA|FILE_WRITE_DATA))==
                (FILE_READ_DATA|FILE_WRITE_DATA)) {
            d_printf("RDWR       ");
        } else if (e->access_mask & FILE_WRITE_DATA) {
            d_printf("WRONLY     ");
        } else {
            d_printf("RDONLY     ");
        }

        if((e->op_type & (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) ==
                (EXCLUSIVE_OPLOCK|BATCH_OPLOCK)) {
            d_printf("EXCLUSIVE+BATCH ");
        } else if (e->op_type & EXCLUSIVE_OPLOCK) {
            d_printf("EXCLUSIVE       ");
        } else if (e->op_type & BATCH_OPLOCK) {
            d_printf("BATCH           ");
        } else if (e->op_type & LEVEL_II_OPLOCK) {
            d_printf("LEVEL_II        ");
        } else {
            d_printf("NONE            ");
        }

        d_printf(" %s   %s   %s",sharepath, fname, time_to_asc((time_t)e->time.tv_sec));
    }
}